android.view.Window.findViewById()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中android.view.Window.findViewById()方法的一些代码示例,展示了Window.findViewById()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.findViewById()方法的具体详情如下:
包路径:android.view.Window
类名称:Window
方法名:findViewById

Window.findViewById介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

Rect rectangle = new Rect();
Window window = getWindow();
window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
int statusBarHeight = rectangle.top;
int contentViewTop = 
  window.findViewById(Window.ID_ANDROID_CONTENT).getTop();
int titleBarHeight= contentViewTop - statusBarHeight;

  Log.i("*** Elenasys :: ", "StatusBar Height= " + statusBarHeight + " , TitleBar Height = " + titleBarHeight);

代码示例来源:origin: stackoverflow.com

Rect rectgle= new Rect();
Window window= getWindow();
window.getDecorView().getWindowVisibleDisplayFrame(rectgle);
int StatusBarHeight= rectgle.top;
int contentViewTop= 
  window.findViewById(Window.ID_ANDROID_CONTENT).getTop();
int TitleBarHeight= contentViewTop - StatusBarHeight;

  Log.i("*** Jorgesys :: ", "StatusBar Height= " + StatusBarHeight + " , TitleBar Height = " + TitleBarHeight);

代码示例来源:origin: cymcsg/UltimateAndroid

/**
 * Get height of the top
 * @param activity
 * @return
 */
public static int getTopBarHeight(Activity activity) {
  return activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT).getTop();
}

代码示例来源:origin: robolectric/robolectric

/**
 * @return the {@code contentView} set by one of the {@code setContentView()} methods
 */
public View getContentView() {
 return ((ViewGroup) getWindow().findViewById(android.R.id.content)).getChildAt(0);
}

代码示例来源:origin: rey5137/material

/**
 * Show this SnackBar. It will auto attach to the activity's root view.
 * @param activity
 */
public void show(Activity activity){
  show((ViewGroup)activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT));
}

代码示例来源:origin: libgdx/libgdx

final View content = dialog.getWindow().findViewById(Window.ID_ANDROID_CONTENT);
content.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
  int[] screenloc = new int[2];

代码示例来源:origin: libgdx/libgdx

final View content = dialog.getWindow().findViewById(Window.ID_ANDROID_CONTENT);
content.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
  int[] screenloc = new int[2];

代码示例来源:origin: robolectric/robolectric

/**
 * Checks to ensure that the{@code contentView} has been set
 *
 * @param id ID of the view to find
 * @return the view
 * @throws RuntimeException if the {@code contentView} has not been called first
 */
@Implementation
protected View findViewById(int id) {
 return getWindow().findViewById(id);
}

代码示例来源:origin: niorgai/StatusBarCompat

/**
 * set StatusBarColor
 *
 * 1. set Flags to call setStatusBarColor
 * 2. call setSystemUiVisibility to clear translucentStatusBar's Flag.
 * 3. set FitsSystemWindows to false
 */
static void setStatusBarColor(Activity activity, int statusColor) {
  Window window = activity.getWindow();
  window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  window.setStatusBarColor(statusColor);
  window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
  ViewGroup mContentView = (ViewGroup) window.findViewById(Window.ID_ANDROID_CONTENT);
  View mChildView = mContentView.getChildAt(0);
  if (mChildView != null) {
    ViewCompat.setFitsSystemWindows(mChildView, false);
    ViewCompat.requestApplyInsets(mChildView);
  }
}

代码示例来源:origin: niorgai/StatusBarCompat

/**
 * translucentStatusBar(full-screen)
 *
 * 1. set Flags to full-screen
 * 2. set FitsSystemWindows to false
 *
 * @param hideStatusBarBackground hide statusBar's shadow
 */
static void translucentStatusBar(Activity activity, boolean hideStatusBarBackground) {
  Window window = activity.getWindow();
  window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  if (hideStatusBarBackground) {
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.setStatusBarColor(Color.TRANSPARENT);
    window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
  } else {
    window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
  }
  ViewGroup mContentView = (ViewGroup) window.findViewById(Window.ID_ANDROID_CONTENT);
  View mChildView = mContentView.getChildAt(0);
  if (mChildView != null) {
    ViewCompat.setFitsSystemWindows(mChildView, false);
    ViewCompat.requestApplyInsets(mChildView);
  }
}

代码示例来源:origin: aa112901/remusic

Window window = alertDialog.getWindow();
window.setContentView(R.layout.dialog);
final EditText editText = (EditText) (window.findViewById(R.id.message));
editText.requestFocus();
(window.findViewById(R.id.positiveButton)).setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
(window.findViewById(R.id.negativeButton)).setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {

代码示例来源:origin: aa112901/remusic

Window window = alertDialog.getWindow();
window.setContentView(R.layout.dialog);
final EditText editText = (EditText) (window.findViewById(R.id.message));
editText.requestFocus();
(window.findViewById(R.id.positiveButton)).setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
(window.findViewById(R.id.negativeButton)).setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {

代码示例来源:origin: niorgai/StatusBarCompat

/**
 * set StatusBarColor
 *
 * 1. set Window Flag : WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
 * 2. removeFakeStatusBarViewIfExist
 * 3. addFakeStatusBarView
 * 4. addMarginTopToContentChild
 * 5. cancel ContentChild's fitsSystemWindow
 */
static void setStatusBarColor(Activity activity, int statusColor) {
  Window window = activity.getWindow();
  window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  ViewGroup mContentView = (ViewGroup) window.findViewById(Window.ID_ANDROID_CONTENT);
  View mContentChild = mContentView.getChildAt(0);
  int statusBarHeight = getStatusBarHeight(activity);
  removeFakeStatusBarViewIfExist(activity);
  addFakeStatusBarView(activity, statusColor, statusBarHeight);
  addMarginTopToContentChild(mContentChild, statusBarHeight);
  if (mContentChild != null) {
    ViewCompat.setFitsSystemWindows(mContentChild, false);
  }
}

代码示例来源:origin: niorgai/StatusBarCompat

ViewGroup mContentView = (ViewGroup) window.findViewById(Window.ID_ANDROID_CONTENT);
View mChildView = mContentView.getChildAt(0);
if (mChildView != null) {

代码示例来源:origin: Hitomis/ActivitySwitcher

private final FrameLayout getContentView(Window window) {
  if(window == null) return null;
  return (FrameLayout) window.findViewById(Window.ID_ANDROID_CONTENT);
}

代码示例来源:origin: jingle1267/android-utils

public View findViewById(final int id) {
  return window.findViewById(id);
}

代码示例来源:origin: niorgai/StatusBarCompat

Window window = activity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
ViewGroup mContentView = (ViewGroup) window.findViewById(Window.ID_ANDROID_CONTENT);

代码示例来源:origin: huxq17/XRefreshView

/**
 * 标题栏高度
 *
 * @return
 */
public static int getTitleHeight(Activity activity) {
  return activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT).getTop();
}

代码示例来源:origin: stackoverflow.com

Rect rectangle = new Rect();
Window window = getWindow();
window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
int statusBarHeight = rectangle.top;
int contentViewTop = window.findViewById(Window.ID_ANDROID_CONTENT).getTop();
int titleBarHeight= contentViewTop - statusBarHeight;

Log.i("*** Value :: ", "StatusBar Height= " + statusBarHeight + " , TitleBar Height = " + titleBarHeight);

代码示例来源:origin: chaychan/TouTiao

static void setContentTopPadding(Activity activity, int padding) {
  ViewGroup mContentView = (ViewGroup) activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT);
  mContentView.setPadding(0, padding, 0, 0);
}

相关文章

Window类方法