Java Code Examples for android.view.WindowInsets#getSystemWindowInsetTop()
The following examples show how to use
android.view.WindowInsets#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: ContainerViewManager.java From Paginize with MIT License | 6 votes |
@TargetApi(20) public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) { if (insets != null) { if (mApplyInsetsToShadow && mShadowView != null) { MarginLayoutParams lp = (MarginLayoutParams)mShadowView.getLayoutParams(); if (lp.topMargin != insets.getSystemWindowInsetTop()) { lp.topMargin = insets.getSystemWindowInsetTop(); } } final int childCount = getChildCount(); for (int i = 0; i < childCount; ++i) { getChildAt(i).dispatchApplyWindowInsets(insets); } } return insets; }
Example 2
Source File: DrawerLayoutContainer.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@SuppressLint("NewApi") private void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity, boolean topOnly) { WindowInsets wi = (WindowInsets) insets; if (drawerGravity == Gravity.LEFT) { wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom()); } else if (drawerGravity == Gravity.RIGHT) { wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom()); } lp.leftMargin = wi.getSystemWindowInsetLeft(); lp.topMargin = topOnly ? 0 : wi.getSystemWindowInsetTop(); lp.rightMargin = wi.getSystemWindowInsetRight(); lp.bottomMargin = wi.getSystemWindowInsetBottom(); }
Example 3
Source File: InsetsDrawerLayout.java From Interessant with Apache License 2.0 | 6 votes |
@Override public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { int l = insets.getSystemWindowInsetLeft(); int t = insets.getSystemWindowInsetTop(); int r = insets.getSystemWindowInsetRight(); toolbar.setPadding(l, toolbar.getPaddingTop() + t, 0, 0); final boolean ltr = recyclerView.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR; setPadding(getPaddingLeft(), getPaddingTop(), getPaddingEnd() + (ltr ? r : 0), getPaddingBottom() ); setOnApplyWindowInsetsListener(null); return insets.consumeSystemWindowInsets(); }
Example 4
Source File: InsetsDispatcherHelper.java From insets-dispatcher with Apache License 2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.KITKAT_WATCH) public WindowInsets onApplyWindowInsets(@Nullable WindowInsets insets) { if (insets != null) { mInsets = new Rect(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom()); } for (int i = 0; i < mView.getChildCount(); i++) { final View child = mView.getChildAt(i); if (!(child instanceof InsetsDispatchReceiver)) { InsetsDispatcherLayoutParamsHelper helper = ((InsetsDispatcherLayoutParams) child.getLayoutParams()).getHelper(); if (helper != null) { applyInsets(mInsets, child, helper.useLeftInset, helper.useTopInset, helper.useRightInset, helper.useBottomInset, helper.insetsUseMargin); } else { applyInsets(mInsets, child, false, false, false, false, false); } } } applyInsets(mInsets, mView, mUseLeftInset, mUseTopInset, mUseRightInset, mUseBottomInset, mInsetsUseMargin); ViewCompat.postInvalidateOnAnimation(mView); return insets; }
Example 5
Source File: DrawerLayoutCompatApi21.java From 920-text-editor-v2 with Apache License 2.0 | 5 votes |
public static void applyMarginInsets(ViewGroup.MarginLayoutParams lp, Object insets, int gravity) { WindowInsets wi = (WindowInsets) insets; if (gravity == Gravity.LEFT) { wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom()); } else if (gravity == Gravity.RIGHT) { wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom()); } lp.leftMargin = wi.getSystemWindowInsetLeft(); lp.topMargin = wi.getSystemWindowInsetTop(); lp.rightMargin = wi.getSystemWindowInsetRight(); lp.bottomMargin = wi.getSystemWindowInsetBottom(); }
Example 6
Source File: DrawerLayoutCompatApi21.java From debugdrawer with Apache License 2.0 | 5 votes |
public static void applyMarginInsets(ViewGroup.MarginLayoutParams lp, Object insets, int gravity) { WindowInsets wi = (WindowInsets) insets; if (gravity == Gravity.LEFT) { wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom()); } else if (gravity == Gravity.RIGHT) { wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom()); } lp.leftMargin = wi.getSystemWindowInsetLeft(); lp.topMargin = wi.getSystemWindowInsetTop(); lp.rightMargin = wi.getSystemWindowInsetRight(); lp.bottomMargin = wi.getSystemWindowInsetBottom(); }
Example 7
Source File: OverlayView.java From Telecine with Apache License 2.0 | 5 votes |
@Override public WindowInsets onApplyWindowInsets(WindowInsets insets) { ViewGroup.LayoutParams lp = getLayoutParams(); lp.height = insets.getSystemWindowInsetTop(); listener.onResize(); return insets.consumeSystemWindowInsets(); }
Example 8
Source File: DrawerLayoutCompatApi21.java From adt-leanback-support with Apache License 2.0 | 5 votes |
public static void applyMarginInsets(ViewGroup.MarginLayoutParams lp, Object insets, int gravity) { WindowInsets wi = (WindowInsets) insets; if (gravity == Gravity.LEFT) { wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom()); } else if (gravity == Gravity.RIGHT) { wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom()); } lp.leftMargin = wi.getSystemWindowInsetLeft(); lp.topMargin = wi.getSystemWindowInsetTop(); lp.rightMargin = wi.getSystemWindowInsetRight(); lp.bottomMargin = wi.getSystemWindowInsetBottom(); }
Example 9
Source File: DrawerLayout.java From Dashchan with Apache License 2.0 | 5 votes |
@Override public void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity) { WindowInsets wi = (WindowInsets) insets; if (drawerGravity == Gravity.LEFT) { wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom()); } else if (drawerGravity == Gravity.RIGHT) { wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom()); } lp.leftMargin = wi.getSystemWindowInsetLeft(); lp.topMargin = wi.getSystemWindowInsetTop(); lp.rightMargin = wi.getSystemWindowInsetRight(); lp.bottomMargin = wi.getSystemWindowInsetBottom(); }
Example 10
Source File: FitsSystemWindowRelativeLayout.java From ExoMedia with Apache License 2.0 | 5 votes |
@Override @TargetApi(Build.VERSION_CODES.KITKAT_WATCH) public WindowInsets onApplyWindowInsets(WindowInsets insets) { Rect windowInsets = new Rect( insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom() ); fitSystemWindows(windowInsets); return insets; }
Example 11
Source File: StatusBarMarginFrameLayout.java From Phonograph with GNU General Public License v3.0 | 5 votes |
@Override public WindowInsets onApplyWindowInsets(WindowInsets insets) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { MarginLayoutParams lp = (MarginLayoutParams) getLayoutParams(); lp.topMargin = insets.getSystemWindowInsetTop(); setLayoutParams(lp); } return super.onApplyWindowInsets(insets); }
Example 12
Source File: StatusBarView.java From Phonograph with GNU General Public License v3.0 | 5 votes |
@Override public WindowInsets onApplyWindowInsets(WindowInsets insets) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ViewGroup.LayoutParams lp = getLayoutParams(); lp.height = insets.getSystemWindowInsetTop(); setLayoutParams(lp); } return super.onApplyWindowInsets(insets); }
Example 13
Source File: ParallaxBackLayout.java From ParallaxBackLayout with MIT License | 5 votes |
@TargetApi(Build.VERSION_CODES.KITKAT_WATCH) @Override public WindowInsets onApplyWindowInsets(WindowInsets insets) { int top = insets.getSystemWindowInsetTop(); if (mContentView.getLayoutParams() instanceof MarginLayoutParams) { MarginLayoutParams params = (MarginLayoutParams) mContentView.getLayoutParams(); mInsets.set(params.leftMargin, params.topMargin + top, params.rightMargin, params.bottomMargin); } applyWindowInset(); return super.onApplyWindowInsets(insets); }
Example 14
Source File: DrawerLayoutContainer.java From Telegram with GNU General Public License v2.0 | 5 votes |
@SuppressLint("NewApi") private void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity, boolean topOnly) { WindowInsets wi = (WindowInsets) insets; if (drawerGravity == Gravity.LEFT) { wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom()); } else if (drawerGravity == Gravity.RIGHT) { wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom()); } lp.leftMargin = wi.getSystemWindowInsetLeft(); lp.topMargin = topOnly ? 0 : wi.getSystemWindowInsetTop(); lp.rightMargin = wi.getSystemWindowInsetRight(); lp.bottomMargin = wi.getSystemWindowInsetBottom(); }
Example 15
Source File: DrawerLayoutContainer.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@SuppressLint("NewApi") private void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity, boolean topOnly) { WindowInsets wi = (WindowInsets) insets; if (drawerGravity == Gravity.LEFT) { wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom()); } else if (drawerGravity == Gravity.RIGHT) { wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom()); } lp.leftMargin = wi.getSystemWindowInsetLeft(); lp.topMargin = topOnly ? 0 : wi.getSystemWindowInsetTop(); lp.rightMargin = wi.getSystemWindowInsetRight(); lp.bottomMargin = wi.getSystemWindowInsetBottom(); }
Example 16
Source File: DrawerLayoutCompatApi21.java From u2020 with Apache License 2.0 | 5 votes |
public static void applyMarginInsets(ViewGroup.MarginLayoutParams lp, Object insets, int gravity) { WindowInsets wi = (WindowInsets) insets; if (gravity == Gravity.LEFT) { wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom()); } else if (gravity == Gravity.RIGHT) { wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom()); } lp.leftMargin = wi.getSystemWindowInsetLeft(); lp.topMargin = wi.getSystemWindowInsetTop(); lp.rightMargin = wi.getSystemWindowInsetRight(); lp.bottomMargin = wi.getSystemWindowInsetBottom(); }
Example 17
Source File: StatusBarView.java From VinylMusicPlayer with GNU General Public License v3.0 | 5 votes |
@Override public WindowInsets onApplyWindowInsets(WindowInsets insets) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ViewGroup.LayoutParams lp = getLayoutParams(); lp.height = insets.getSystemWindowInsetTop(); setLayoutParams(lp); } return super.onApplyWindowInsets(insets); }
Example 18
Source File: StatusBarMarginFrameLayout.java From Music-Player with GNU General Public License v3.0 | 5 votes |
@Override public WindowInsets onApplyWindowInsets(WindowInsets insets) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { MarginLayoutParams lp = (MarginLayoutParams) getLayoutParams(); lp.topMargin = insets.getSystemWindowInsetTop(); setLayoutParams(lp); } return super.onApplyWindowInsets(insets); }
Example 19
Source File: StatusBarView.java From Music-Player with GNU General Public License v3.0 | 5 votes |
@Override public WindowInsets onApplyWindowInsets(WindowInsets insets) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ViewGroup.LayoutParams lp = getLayoutParams(); lp.height = insets.getSystemWindowInsetTop(); setLayoutParams(lp); } return super.onApplyWindowInsets(insets); }
Example 20
Source File: NoInsertLinearLayout.java From Socket.io-FLSocketIM-Android with MIT License | 5 votes |
@Override public WindowInsets onApplyWindowInsets(WindowInsets insets) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { mInsets[0] = insets.getSystemWindowInsetLeft(); mInsets[1] = insets.getSystemWindowInsetTop(); mInsets[2] = insets.getSystemWindowInsetRight(); return super.onApplyWindowInsets(insets.replaceSystemWindowInsets(0, 0, 0, insets.getSystemWindowInsetBottom())); } else { return super.onApplyWindowInsets(insets); } }