final int height = bottom - top; parent.getWindowVisibleDisplayFrame(mTmpRect); final int windowWidth = mTmpRect.width(); final int windowHeight = mTmpRect.height();
SnackbarView snackbarView = snackbarLayout.getView(); Rect windowFrame = new Rect(); container.getWindowVisibleDisplayFrame(windowFrame); Rect drawingRect = new Rect(); container.getDrawingRect(drawingRect);
resourceFinder.getPromptParentView().getWindowVisibleDisplayFrame(rect); mStatusBarHeight = rect.top;
SlidePropagation() { Rect windowInsets = new Rect(); MassSlideAnimator.this.mRoot.getWindowVisibleDisplayFrame(windowInsets); this.mWindowHeight = windowInsets.height(); }
public SlidePropagation() { Rect windowInsets = new Rect(); MassSlideAnimator.this.mRoot.getWindowVisibleDisplayFrame(windowInsets); this.mWindowHeight = windowInsets.height(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ViewGroup decorView = (ViewGroup) this.getWindow().getDecorView(); decorView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (Build.VERSION.SDK_INT >= 16) { decorView.getViewTreeObserver().removeOnGlobalLayoutListener(this); } else { // Nice one, Google decorView.getViewTreeObserver().removeGlobalOnLayoutListener(this); } Rect rect = new Rect(); decorView.getWindowVisibleDisplayFrame(rect); rect.top; // This is the height of the status bar } } }
mDecorView.getWindowVisibleDisplayFrame(visibleDisplayRect);
void adjustViewPosition() { mParent.getWindowVisibleDisplayFrame(mCurrentVisibleRect); // Only update if the visible frame has changed, otherwise there will be a layout loop. if (!mCurrentVisibleRect.equals(mPreviousVisibleRect)) { mPreviousVisibleRect.set(mCurrentVisibleRect); int keyboardHeight = mParent.getHeight() - mCurrentVisibleRect.bottom + mCurrentVisibleRect.top; MarginLayoutParams lp = getLayoutParams(); lp.bottomMargin = keyboardHeight; if (mIsTablet) { int margin = mParent.getResources() .getDimensionPixelSize(R.dimen.snackbar_margin_tablet); ApiCompatibilityUtils.setMarginStart(lp, margin); lp.bottomMargin += margin; int width = mParent.getResources() .getDimensionPixelSize(R.dimen.snackbar_width_tablet); lp.width = Math.min(width, mParent.getWidth() - 2 * margin); } mView.setLayoutParams(lp); } }
rootView.getWindowVisibleDisplayFrame(rect); int[] etLocation = new int[2]; editText.getLocationOnScreen(etLocation);
mRootView.getWindowVisibleDisplayFrame(rect);
mRootView.getWindowVisibleDisplayFrame(rect);