Java Code Examples for androidx.core.view.WindowInsetsCompat#getSystemWindowInsetTop()
The following examples show how to use
androidx.core.view.WindowInsetsCompat#getSystemWindowInsetTop() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CoordinatorScrollingFrameLayout.java From AndroidFastScroll with Apache License 2.0 | 6 votes |
@Override public boolean onMeasureChild(@NonNull CoordinatorLayout parent, @NonNull View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) { @SuppressLint("RestrictedApi") WindowInsetsCompat parentInsets = parent.getLastWindowInsets(); if (parentInsets != null) { int parentHeightSize = MeasureSpec.getSize(parentHeightMeasureSpec); parentHeightSize -= parentInsets.getSystemWindowInsetTop() + parentInsets.getSystemWindowInsetBottom(); int parentHeightMode = MeasureSpec.getMode(parentHeightMeasureSpec); parentHeightMeasureSpec = MeasureSpec.makeMeasureSpec(parentHeightSize, parentHeightMode); } return super.onMeasureChild(parent, child, parentWidthMeasureSpec, widthUsed, parentHeightMeasureSpec, heightUsed); }
Example 2
Source File: MaterialDialogDecorator.java From AndroidMaterialDialog with Apache License 2.0 | 6 votes |
/** * Creates and returns a listener, which allows to observe when window insets are applied to the * root view of the view hierarchy, which is modified by the decorator. * * @return The listener, which has been created, as an instance of the type {@link * OnApplyWindowInsetsListener} */ private OnApplyWindowInsetsListener createWindowInsetsListener() { return new OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(final View v, final WindowInsetsCompat insets) { systemWindowInsets = insets.hasSystemWindowInsets() ? new Rect(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom()) : null; adaptLayoutParams(); return insets; } }; }
Example 3
Source File: WindowInsetsFrameLayout.java From earth with GNU General Public License v3.0 | 6 votes |
@TargetApi(21) private boolean applySystemWindowInsets21(WindowInsetsCompat insets) { boolean consumed = false; for (int i = 0; i < getChildCount(); i++) { View child = getChildAt(i); if (!child.getFitsSystemWindows()) { continue; } Rect childInsets = new Rect( insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom()); computeInsetsWithGravity(child, childInsets); ViewCompat.dispatchApplyWindowInsets(child, insets.replaceSystemWindowInsets(childInsets)); consumed = true; } return consumed; }
Example 4
Source File: HomeScreenFragment.java From ground-android with Apache License 2.0 | 5 votes |
private void updateBottomSheetPeekHeight(WindowInsetsCompat insets) { double width = getScreenWidth(getActivity()) + insets.getSystemWindowInsetLeft() + insets.getSystemWindowInsetRight(); double height = getScreenHeight(getActivity()) + insets.getSystemWindowInsetTop() + insets.getSystemWindowInsetBottom(); double mapHeight = width / COLLAPSED_MAP_ASPECT_RATIO; double peekHeight = height - mapHeight; bottomSheetBehavior.setPeekHeight((int) peekHeight); }
Example 5
Source File: MainActivity.java From ChromeLikeTabSwitcher with Apache License 2.0 | 5 votes |
/** * Creates a listener, which allows to apply the window insets to the tab switcher's padding. * * @return The listener, which has been created, as an instance of the type {@link * OnApplyWindowInsetsListener}. The listener may not be nullFG */ @NonNull private OnApplyWindowInsetsListener createWindowInsetsListener() { return new OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(final View v, final WindowInsetsCompat insets) { int left = insets.getSystemWindowInsetLeft(); int top = insets.getSystemWindowInsetTop(); int right = insets.getSystemWindowInsetRight(); int bottom = insets.getSystemWindowInsetBottom(); tabSwitcher.setPadding(left, top, right, bottom); float touchableAreaTop = top; if (tabSwitcher.getLayout() == Layout.TABLET) { touchableAreaTop += getResources() .getDimensionPixelSize(R.dimen.tablet_tab_container_height); } RectF touchableArea = new RectF(left, touchableAreaTop, getDisplayWidth(MainActivity.this) - right, touchableAreaTop + ThemeUtil.getDimensionPixelSize(MainActivity.this, R.attr.actionBarSize)); tabSwitcher.addDragGesture( new SwipeGesture.Builder().setTouchableArea(touchableArea).create()); tabSwitcher.addDragGesture( new PullDownGesture.Builder().setTouchableArea(touchableArea).create()); return insets; } }; }
Example 6
Source File: NavigationMenuPresenter.java From material-components-android with Apache License 2.0 | 5 votes |
public void dispatchApplyWindowInsets(@NonNull WindowInsetsCompat insets) { int top = insets.getSystemWindowInsetTop(); if (paddingTopDefault != top) { paddingTopDefault = top; // Apply the padding to the top of the view if it has changed. updateTopPadding(); } // Always apply the bottom padding. menuView.setPadding(0, menuView.getPaddingTop(), 0, insets.getSystemWindowInsetBottom()); ViewCompat.dispatchApplyWindowInsets(headerLayout, insets); }