@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; }
if (applied.isConsumed()) { res.left = applied.getSystemWindowInsetLeft(); res.top = applied.getSystemWindowInsetTop(); res.right = applied.getSystemWindowInsetRight(); res.bottom = applied.getSystemWindowInsetBottom(); = Math.min(childInsets.getSystemWindowInsetLeft(), res.left); res.top = Math.min(childInsets.getSystemWindowInsetTop(), res.top); res.right = Math.min(childInsets.getSystemWindowInsetRight(), res.right); res.bottom = Math.min(childInsets.getSystemWindowInsetBottom(), res.bottom); return applied.replaceSystemWindowInsets( res.left, res.top, res.right, res.bottom);
public OpaqueStatusBarRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); TypedArray ta = context.obtainStyledAttributes( attrs, R.styleable.OpaqueStatusBarRelativeLayout, defStyleAttr, 0); mInsetDrawable = ta.getDrawable(R.styleable.OpaqueStatusBarRelativeLayout_colorPrimaryDark); ta.recycle(); setWillNotDraw(false); ViewCompat.setOnApplyWindowInsetsListener(this, (View v, WindowInsetsCompat insets) -> { mTopInset = insets.getSystemWindowInsetTop(); setPadding(0, mTopInset, 0, 0); ViewCompat.postInvalidateOnAnimation(this); return insets.consumeSystemWindowInsets(); }); setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); }
public void dispatchApplyWindowInsets(WindowInsetsCompat insets) { int top = insets.getSystemWindowInsetTop(); if (mPaddingTopDefault != top) { mPaddingTopDefault = top; if (mHeaderLayout.getChildCount() == 0) { mMenuView.setPadding(0, mPaddingTopDefault, 0, mMenuView.getPaddingBottom()); } } ViewCompat.dispatchApplyWindowInsets(mHeaderLayout, 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(); }); }