res.left = applied.getSystemWindowInsetLeft(); res.top = applied.getSystemWindowInsetTop(); res.right = applied.getSystemWindowInsetRight(); = Math.min(childInsets.getSystemWindowInsetLeft(), res.left); res.top = Math.min(childInsets.getSystemWindowInsetTop(),
@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; }
@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; }
@Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { if (null == mInsets) { mInsets = new Rect(); } mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom()); setWillNotDraw(mInsetForeground == null); ViewCompat.postInvalidateOnAnimation(ScrimInsetsRelativeLayout.this); if (mOnInsetsCallback != null) { mOnInsetsCallback.onInsetsChanged(insets); } return insets.consumeSystemWindowInsets(); } });
@Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { if (null == mInsets) { mInsets = new Rect(); } mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom()); setWillNotDraw(mInsetForeground == null); ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this); if (mOnInsetsCallback != null) { mOnInsetsCallback.onInsetsChanged(insets); } return insets.consumeSystemWindowInsets(); } });
public DrawerScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DrawerScrimInsetsFrameLayout, defStyleAttr, R.style.Widget_Drawer_DrawerScrimInsetsFrameLayout); mInsetForeground = a.getDrawable(R.styleable.DrawerScrimInsetsFrameLayout_insetForeground); a.recycle(); setWillNotDraw(true); // No need to draw until the insets are adjusted ViewCompat.setOnApplyWindowInsetsListener(this, (v, insets) -> { if (null == mInsets) { mInsets = new Rect(); } mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom()); onInsetsChanged(insets); setWillNotDraw(!insets.hasSystemWindowInsets() || mInsetForeground == null); ViewCompat.postInvalidateOnAnimation(DrawerScrimInsetsFrameLayout.this); return insets.consumeSystemWindowInsets(); }); }