public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); this.mTempRect = new Rect(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsFrameLayout, defStyleAttr, R.style.Widget_Design_ScrimInsetsFrameLayout); this.mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsFrameLayout_insetForeground); a.recycle(); setWillNotDraw(true); ViewCompat.setOnApplyWindowInsetsListener(this, new OnApplyWindowInsetsListener() { public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { if (ScrimInsetsFrameLayout.this.mInsets == null) { ScrimInsetsFrameLayout.this.mInsets = new Rect(); } ScrimInsetsFrameLayout.this.mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom()); ScrimInsetsFrameLayout.this.onInsetsChanged(ScrimInsetsFrameLayout.this.mInsets); ScrimInsetsFrameLayout scrimInsetsFrameLayout = ScrimInsetsFrameLayout.this; boolean z = ScrimInsetsFrameLayout.this.mInsets.isEmpty() || ScrimInsetsFrameLayout.this.mInsetForeground == null; scrimInsetsFrameLayout.setWillNotDraw(z); ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this); return insets.consumeSystemWindowInsets(); } }); }
public AppBarLayout(Context context, AttributeSet attrs) { super(context, attrs); this.mTotalScrollRange = -1; this.mDownPreScrollRange = -1; this.mDownScrollRange = -1; this.mPendingAction = 0; setOrientation(1); ThemeUtils.checkAppCompatTheme(context); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AppBarLayout, 0, R.style.Widget_Design_AppBarLayout); this.mTargetElevation = (float) a.getDimensionPixelSize(R.styleable.AppBarLayout_elevation, 0); setBackgroundDrawable(a.getDrawable(R.styleable.AppBarLayout_android_background)); if (a.hasValue(R.styleable.AppBarLayout_expanded)) { setExpanded(a.getBoolean(R.styleable.AppBarLayout_expanded, false)); } a.recycle(); ViewUtils.setBoundsViewOutlineProvider(this); this.mListeners = new ArrayList(); ViewCompat.setElevation(this, this.mTargetElevation); ViewCompat.setOnApplyWindowInsetsListener(this, new OnApplyWindowInsetsListener() { public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { return AppBarLayout.this.onWindowInsetChanged(insets); } }); }
private WindowInsetsCompat setWindowInsets(WindowInsetsCompat insets) { boolean z = true; if (this.mLastInsets == insets) { return insets; } this.mLastInsets = insets; boolean z2 = insets != null && insets.getSystemWindowInsetTop() > 0; this.mDrawStatusBarBackground = z2; if (this.mDrawStatusBarBackground || getBackground() != null) { z = false; } setWillNotDraw(z); insets = dispatchApplyWindowInsetsToBehaviors(insets); requestLayout(); return insets; }
private void setupForInsets() { if (Build.VERSION.SDK_INT < 21) { return; } if (ViewCompat.getFitsSystemWindows(this)) { if (applyWindowInsetsListener == null) { applyWindowInsetsListener = new android.support.v4.view.OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { return setWindowInsets(insets); } }; } // First apply the insets listener ViewCompat.setOnApplyWindowInsetsListener(this, applyWindowInsetsListener); // Now set the sys ui flags to enable us to lay out in the window insets setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); } else { ViewCompat.setOnApplyWindowInsetsListener(this, null); } }
public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsFrameLayout, defStyleAttr, R.style.Widget_Design_ScrimInsetsFrameLayout); mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsFrameLayout_insetForeground); a.recycle(); setWillNotDraw(true); // No need to draw until the insets are adjusted ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() { @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(mInsets.isEmpty() || mInsetForeground == null); ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this); return insets.consumeSystemWindowInsets(); } }); }
/** * 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; } }; }
/** * set StatusBarColor */ public static void setStatusBarColor(Activity activity, int statusColor) { Window window = activity.getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(statusColor); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); ViewGroup mContentView = (ViewGroup) window.findViewById(Window.ID_ANDROID_CONTENT); View mChildView = mContentView.getChildAt(0); if (mChildView != null) { ViewCompat.setOnApplyWindowInsetsListener(mChildView, new OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { return insets; } }); ViewCompat.setFitsSystemWindows(mChildView, true); ViewCompat.requestApplyInsets(mChildView); } }
private WindowInsetsCompat setWindowInsets(WindowInsetsCompat insets) { if (Build.VERSION.SDK_INT >= 21 && mWindowInsetLayoutWR.get() != null) { if (mWindowInsetLayoutWR.get().applySystemWindowInsets21(insets)) { return insets.consumeSystemWindowInsets(); } } return insets; }
WindowInsetsCompat onWindowInsetChanged(final WindowInsetsCompat insets) { WindowInsetsCompat newInsets = null; if (ViewCompat.getFitsSystemWindows(this)) { // If we're set to fit system windows, keep the insets newInsets = insets; } // If our insets have changed, keep them and invalidate the scroll ranges... if (!QMUILangHelper.objectEquals(mLastInsets, newInsets)) { mLastInsets = newInsets; requestLayout(); } // Consume the insets. This is done so that child views with fitSystemWindows=true do not // get the default padding functionality from View return insets.consumeSystemWindowInsets(); }
WindowInsetsCompat onWindowInsetChanged(final WindowInsetsCompat insets) { WindowInsetsCompat newInsets = null; if (ViewCompat.getFitsSystemWindows(this)) { // If we're set to fit system windows, keep the insets newInsets = insets; } // If our insets have changed, keep them and invalidate the scroll ranges... if (!ObjectsCompat.equals(mLastInsets, newInsets)) { mLastInsets = newInsets; invalidateScrollRanges(); } return insets; }
private WindowInsetsCompat dispatchApplyWindowInsetsToBehaviors(WindowInsetsCompat insets) { if (insets.isConsumed()) { return insets; } for (int i = 0, z = getChildCount(); i < z; i++) { final View child = getChildAt(i); if (ViewCompat.getFitsSystemWindows(child)) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); final Behavior b = lp.getBehavior(); if (b != null) { // If the view has a behavior, let it try first insets = b.onApplyWindowInsets(this, child, insets); if (insets.isConsumed()) { // If it consumed the insets, break break; } } } } return insets; }
private void setupForInsets() { if (Build.VERSION.SDK_INT < 21) { return; } if (ViewCompat.getFitsSystemWindows(this)) { if (mApplyWindowInsetsListener == null) { mApplyWindowInsetsListener = new android.support.v4.view.OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { return setWindowInsets(insets); } }; } // First apply the insets listener ViewCompat.setOnApplyWindowInsetsListener(this, mApplyWindowInsetsListener); // Now set the sys ui flags to enable us to lay out in the window insets setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); } else { ViewCompat.setOnApplyWindowInsetsListener(this, null); } }
private WindowInsetsCompat dispatchApplyWindowInsetsToBehaviors(WindowInsetsCompat insets) { if (insets.isConsumed()) { return insets; } int z = getChildCount(); for (int i = 0; i < z; i++) { View child = getChildAt(i); if (ViewCompat.getFitsSystemWindows(child)) { Behavior b = ((LayoutParams) child.getLayoutParams()).getBehavior(); if (b != null) { insets = b.onApplyWindowInsets(this, child, insets); if (insets.isConsumed()) { break; } } else { continue; } } } return insets; }
@Override public boolean applySystemWindowInsets21(WindowInsetsCompat insets) { WindowInsetsCompat newInsets = null; if (ViewCompat.getFitsSystemWindows(this)) { // If we're set to fit system windows, keep the insets newInsets = insets; } // If our insets have changed, keep them and invalidate the scroll ranges... if (!QMUILangHelper.objectEquals(mLastInsets, newInsets)) { mLastInsets = newInsets; requestLayout(); } return true; }
public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); this.mTempRect = new Rect(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SnvScrimInsetsFrameLayout, defStyleAttr, R.style.SnvScrimInsetsFrameLayout); this.mInsetForeground = a.getDrawable(R.styleable.SnvScrimInsetsFrameLayout_snvInsetForeground); a.recycle(); this.setWillNotDraw(true); ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() { public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { if (null == ScrimInsetsFrameLayout.this.mInsets) { ScrimInsetsFrameLayout.this.mInsets = new Rect(); } ScrimInsetsFrameLayout.this.mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom()); ScrimInsetsFrameLayout.this.setWillNotDraw(ScrimInsetsFrameLayout.this.mInsets.isEmpty() || ScrimInsetsFrameLayout.this.mInsetForeground == null); ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this); return insets.consumeSystemWindowInsets(); } }); }
WindowInsetsCompat onWindowInsetChanged(final WindowInsetsCompat insets) { WindowInsetsCompat newInsets = null; if (ViewCompat.getFitsSystemWindows(this)) { // If we're set to fit system windows, keep the insets newInsets = insets; } // If our insets have changed, keep them and invalidate the scroll ranges... if (!ObjectsCompat.equals(lastInsets, newInsets)) { lastInsets = newInsets; invalidateScrollRanges(); } return insets; }
WindowInsetsCompat onWindowInsetChanged(final WindowInsetsCompat insets) { WindowInsetsCompat newInsets = null; if (ViewCompat.getFitsSystemWindows(this)) { // If we're set to fit system windows, keep the insets newInsets = insets; } // If our insets have changed, keep them and invalidate the scroll ranges... if (!ObjectsCompat.equals(lastInsets, newInsets)) { lastInsets = newInsets; requestLayout(); } // Consume the insets. This is done so that child views with fitSystemWindows=true do not // get the default padding functionality from View return insets.consumeSystemWindowInsets(); }
private void setWindowInsets(WindowInsetsCompat insets) { if (mLastInsets != insets) { mLastInsets = insets; mDrawStatusBarBackground = insets != null && insets.getSystemWindowInsetTop() > 0; if (insets != null) { if (insets.isRound()) { if (!(mEdgeGlowTop instanceof CrescentEdgeEffect)) { mEdgeGlowTop = new CrescentEdgeEffect(getContext()); mEdgeGlowBottom = new CrescentEdgeEffect(getContext()); } } else { if (!(mEdgeGlowTop instanceof ClassicEdgeEffect)) { mEdgeGlowTop = new ClassicEdgeEffect(getContext()); mEdgeGlowBottom = new ClassicEdgeEffect(getContext()); } } mScrollBarHelper.setIsRound(insets.isRound()); } setWillNotDraw(!mDrawStatusBarBackground && getBackground() == null && mEdgeGlowTop == null); dispatchChildApplyWindowInsets(insets); requestLayout(); } }
WindowInsetsCompat onWindowInsetChanged(final WindowInsetsCompat insets) { WindowInsetsCompat newInsets = null; if (ViewCompat.getFitsSystemWindows(this)) { // If we're set to fit system windows, keep the insets newInsets = insets; } // If our insets have changed, keep them and invalidate the scroll ranges... if (!ObjectsCompat.equals(mLastInsets, newInsets)) { mLastInsets = newInsets; requestLayout(); } // Consume the insets. This is done so that child views with fitSystemWindows=true do not // get the default padding functionality from View return insets.consumeSystemWindowInsets(); }
@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; }
public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); this.mTempRect = new Rect(); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsFrameLayout, defStyleAttr, R.style.Widget_Design_ScrimInsetsFrameLayout); this.mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsFrameLayout_insetForeground); a.recycle(); this.setWillNotDraw(true); ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() { public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { if (null == ScrimInsetsFrameLayout.this.mInsets) { ScrimInsetsFrameLayout.this.mInsets = new Rect(); } ScrimInsetsFrameLayout.this.mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom()); ScrimInsetsFrameLayout.this.setWillNotDraw(ScrimInsetsFrameLayout.this.mInsets.isEmpty() || ScrimInsetsFrameLayout.this.mInsetForeground == null); ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this); return insets.consumeSystemWindowInsets(); } }); }
WindowInsetsCompat onWindowInsetChanged(final WindowInsetsCompat insets) { WindowInsetsCompat newInsets = null; if (ViewCompat.getFitsSystemWindows(this)) { // If we're set to fit system windows, keep the insets newInsets = insets; } // If our insets have changed, keep them and invalidate the scroll ranges... if (!objectEquals(mLastInsets, newInsets)) { mLastInsets = newInsets; invalidateScrollRanges(); } return insets; }
private void setupForInsets() { if (Build.VERSION.SDK_INT < 21) { return; } if (ViewCompat.getFitsSystemWindows(this)) { if (mApplyWindowInsetsListener == null) { mApplyWindowInsetsListener = new android.support.v4.view.OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { return setWindowInsets(insets); } }; } // First apply the insets listener ViewCompat.setOnApplyWindowInsetsListener(this, mApplyWindowInsetsListener); // Now set the sys ui flags to enable us to lay out in the window insets setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); } else { ViewCompat.setOnApplyWindowInsetsListener(this, null); } }
WindowInsetsCompat onWindowInsetChanged(final WindowInsetsCompat insets) { WindowInsetsCompat newInsets = null; if (ViewCompat.getFitsSystemWindows(this)) { // If we're set to fit system windows, keep the insets newInsets = insets; } // If our insets have changed, keep them and invalidate the scroll ranges... if (!objectEquals(mLastInsets, newInsets)) { mLastInsets = newInsets; requestLayout(); } // Consume the insets. This is done so that child views with fitSystemWindows=true do not // get the default padding functionality from View return insets.consumeSystemWindowInsets(); }
/** * translucentStatusBar(full-screen) * @param hideStatusBarBackground hide statusBar's shadow */ public static void translucentStatusBar(Activity activity, boolean hideStatusBarBackground) { Window window = activity.getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); if (hideStatusBarBackground) { window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(Color.TRANSPARENT); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); } else { window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); } ViewGroup mContentView = (ViewGroup) window.findViewById(Window.ID_ANDROID_CONTENT); View mChildView = mContentView.getChildAt(0); if (mChildView != null) { ViewCompat.setOnApplyWindowInsetsListener(mChildView, new OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { return insets; } }); ViewCompat.setFitsSystemWindows(mChildView, false); ViewCompat.requestApplyInsets(mChildView); } }
/** * compat for CollapsingToolbarLayout */ public static void setStatusBarColorForCollapsingToolbar(Activity activity, final AppBarLayout appBarLayout, CollapsingToolbarLayout collapsingToolbarLayout, Toolbar toolbar, int statusColor) { Window window = activity.getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); ViewGroup mContentView = (ViewGroup) window.findViewById(Window.ID_ANDROID_CONTENT); View mChildView = mContentView.getChildAt(0); if (mChildView != null) { ViewCompat.setOnApplyWindowInsetsListener(mChildView, new OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { return insets; } }); ViewCompat.setFitsSystemWindows(mChildView, true); ViewCompat.requestApplyInsets(mChildView); } ((View) appBarLayout.getParent()).setFitsSystemWindows(true); appBarLayout.setFitsSystemWindows(true); collapsingToolbarLayout.setFitsSystemWindows(true); collapsingToolbarLayout.getChildAt(0).setFitsSystemWindows(true); toolbar.setFitsSystemWindows(false); collapsingToolbarLayout.setStatusBarScrimColor(statusColor); }
public QMUIWindowInsetHelper(ViewGroup viewGroup, IWindowInsetLayout windowInsetLayout) { mWindowInsetLayoutWR = new WeakReference<>(windowInsetLayout); KEYBOARD_HEIGHT_BOUNDARY = QMUIDisplayHelper.dp2px(viewGroup.getContext(), 100); ViewCompat.setOnApplyWindowInsetsListener(viewGroup, new android.support.v4.view.OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { return setWindowInsets(insets); } }); }
@TargetApi(21) public boolean defaultApplySystemWindowInsets21(ViewGroup viewGroup, WindowInsetsCompat insets) { if (!insets.hasSystemWindowInsets()) { return false; } boolean consumed = false; boolean showKeyboard = false; if (insets.getSystemWindowInsetBottom() >= KEYBOARD_HEIGHT_BOUNDARY) { showKeyboard = true; QMUIViewHelper.setPaddingBottom(viewGroup, insets.getSystemWindowInsetBottom()); } else { QMUIViewHelper.setPaddingBottom(viewGroup, 0); } for (int i = 0; i < viewGroup.getChildCount(); i++) { View child = viewGroup.getChildAt(i); if (jumpDispatch(child)) { continue; } Rect childInsets = new Rect( insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), showKeyboard ? 0 : insets.getSystemWindowInsetBottom()); computeInsetsWithGravity(child, childInsets); ViewCompat.dispatchApplyWindowInsets(child, insets.replaceSystemWindowInsets(childInsets)); consumed = true; } return consumed; }
@Override protected void layoutChild(final CoordinatorLayout parent, 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 = mTempRect1; 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 = mTempRect2; 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); mVerticalLayoutGap = out.top - header.getBottom(); } else { // If we don't have a dependency, let super handle it super.layoutChild(parent, child, layoutDirection); mVerticalLayoutGap = 0; } }
final WindowInsetsCompat setWindowInsets(WindowInsetsCompat insets) { if (!ObjectsCompat.equals(mLastInsets, insets)) { mLastInsets = insets; mDrawStatusBarBackground = insets != null && insets.getSystemWindowInsetTop() > 0; setWillNotDraw(!mDrawStatusBarBackground && getBackground() == null); // Now dispatch to the Behaviors insets = dispatchApplyWindowInsetsToBehaviors(insets); requestLayout(); } return insets; }
/** * 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; } }; }
private WindowInsetsCompat onWindowInsetChanged(WindowInsetsCompat insets) { WindowInsetsCompat newInsets = null; if (ViewCompat.getFitsSystemWindows(this)) { newInsets = insets; } if (newInsets != this.mLastInsets) { this.mLastInsets = newInsets; invalidateScrollRanges(); } return insets; }
private WindowInsetsCompat setWindowInsets(WindowInsetsCompat insets) { if (this.mLastInsets != insets) { this.mLastInsets = insets; requestLayout(); } return insets.consumeSystemWindowInsets(); }
private WindowInsetsCompat setWindowInsets(WindowInsetsCompat insets) { if (Build.VERSION.SDK_INT >= 21) { if (applySystemWindowInsets21(insets)) { return insets.consumeSystemWindowInsets(); } } return insets; }