Java Code Examples for androidx.core.view.WindowInsetsCompat#getSystemWindowInsetRight()
The following examples show how to use
androidx.core.view.WindowInsetsCompat#getSystemWindowInsetRight() .
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: 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 2
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 3
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 4
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 5
Source File: HeaderScrollingViewBehavior.java From material-components-android with Apache License 2.0 | 4 votes |
@Override protected void layoutChild( @NonNull final CoordinatorLayout parent, @NonNull final View child, final int layoutDirection) { final List<View> dependencies = parent.getDependencies(child); final View header = findFirstDependency(dependencies); if (header != null) { final CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) child.getLayoutParams(); final Rect available = tempRect1; available.set( parent.getPaddingLeft() + lp.leftMargin, header.getBottom() + lp.topMargin, parent.getWidth() - parent.getPaddingRight() - lp.rightMargin, parent.getHeight() + header.getBottom() - parent.getPaddingBottom() - lp.bottomMargin); final WindowInsetsCompat parentInsets = parent.getLastWindowInsets(); if (parentInsets != null && ViewCompat.getFitsSystemWindows(parent) && !ViewCompat.getFitsSystemWindows(child)) { // If we're set to handle insets but this child isn't, then it has been measured as // if there are no insets. We need to lay it out to match horizontally. // Top and bottom and already handled in the logic above available.left += parentInsets.getSystemWindowInsetLeft(); available.right -= parentInsets.getSystemWindowInsetRight(); } final Rect out = tempRect2; GravityCompat.apply( resolveGravity(lp.gravity), child.getMeasuredWidth(), child.getMeasuredHeight(), available, out, layoutDirection); final int overlap = getOverlapPixelsForOffset(header); child.layout(out.left, out.top - overlap, out.right, out.bottom - overlap); verticalLayoutGap = out.top - header.getBottom(); } else { // If we don't have a dependency, let super handle it super.layoutChild(parent, child, layoutDirection); verticalLayoutGap = 0; } }