window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); ViewCompat.setOnApplyWindowInsetsListener(collapsingToolbarLayout, new OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
ViewCompat.setOnApplyWindowInsetsListener(this, new androidx.core.view.OnApplyWindowInsetsListener() { private final Rect mTempRect = new Rect();
@Override protected final void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); dataBinder = new DataBinder(this); decorator = new Decorator(); tabSwitcher = findViewById(R.id.tab_switcher); tabSwitcher.clearSavedStatesWhenRemovingTabs(false); ViewCompat.setOnApplyWindowInsetsListener(tabSwitcher, createWindowInsetsListener()); tabSwitcher.setDecorator(decorator); tabSwitcher.addListener(this); tabSwitcher.showToolbars(true); for (int i = 0; i < TAB_COUNT; i++) { tabSwitcher.addTab(createTab(i)); } tabSwitcher.showAddTabButton(createAddTabButtonListener()); tabSwitcher.setToolbarNavigationIcon(R.drawable.ic_plus_24dp, createAddTabListener()); TabSwitcher.setupWithMenu(tabSwitcher, createTabSwitcherButtonListener()); inflateMenu(); }
private void init(Context context, AttributeSet attrs, int defStyle) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsView, defStyle, R.style.Widget_Materialize_ScrimInsetsRelativeLayout); mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_siv_insetForeground); a.recycle(); setWillNotDraw(true); // No need to draw until the insets are adjusted ViewCompat.setOnApplyWindowInsetsListener(this, new androidx.core.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(mInsetForeground == null); ViewCompat.postInvalidateOnAnimation(ScrimInsetsFrameLayout.this); if (mOnInsetsCallback != null) { mOnInsetsCallback.onInsetsChanged(insets); } return insets.consumeSystemWindowInsets(); } }); }
public ScrimInsetsRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsRelativeLayout, defStyleAttr, R.style.Widget_Materialize_ScrimInsetsRelativeLayout); mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsRelativeLayout_sirl_insetForeground); a.recycle(); setWillNotDraw(true); // No need to draw until the insets are adjusted ViewCompat.setOnApplyWindowInsetsListener(this, new androidx.core.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(mInsetForeground == null); ViewCompat.postInvalidateOnAnimation(ScrimInsetsRelativeLayout.this); if (mOnInsetsCallback != null) { mOnInsetsCallback.onInsetsChanged(insets); } return insets.consumeSystemWindowInsets(); } }); }
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 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(); }); }
@NonNull final Map<ViewType, View> areas, final Void param) { ViewCompat.setOnApplyWindowInsetsListener(view, createWindowInsetsListener()); View titleView = inflateTitleView(); View messageView = inflateMessageView();
ViewCompat.setOnApplyWindowInsetsListener(mainMenu, new OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {