private void initView() { TAG_ANIMATOR_TRANSLATION_Y = mContext.getResources().getIdentifier("translation_y_animator_tag", "id", PACKAGE_SYSTEMUI); TAG_END_TRANSLATION_Y = mContext.getResources().getIdentifier("translation_y_animator_end_value_tag", "id", PACKAGE_SYSTEMUI); mBackgroundPaint.setColor(0xFFEEEEEE); mBackgroundPaint.setXfermode(mSrcMode); mStackScrollLayout.setWillNotDraw(false); mStackScrollLayout.setOnApplyWindowInsetsListener(NotificationStackScrollLayoutHooks.this); }
@Override @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH) public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) { toolbar.setPadding(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), 0); bottomBarControls.setPadding(insets.getSystemWindowInsetLeft(), 0, insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom()); // clear this listener so insets aren't re-applied rootView.setOnApplyWindowInsetsListener(null); return insets.consumeSystemWindowInsets(); } });
final ViewGroup rootView = findViewById(R.id.root_view); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { rootView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @Override @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
rootView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @Override @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
rootView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @Override @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
final View actionArea = findViewById(R.id.action_area); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { rootView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @Override @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
rootView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @Override @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
rootView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @Override @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
@Override @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH) public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) { toolbar.setPadding(toolbar.getPaddingStart() + insets.getSystemWindowInsetLeft(), toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(), toolbar.getPaddingEnd() + insets.getSystemWindowInsetRight(), toolbar.getPaddingBottom()); recyclerView.setPadding(recyclerView.getPaddingStart() + insets.getSystemWindowInsetLeft(), recyclerView.getPaddingTop(), recyclerView.getPaddingEnd() + insets.getSystemWindowInsetRight(), recyclerView.getPaddingBottom() + insets.getSystemWindowInsetBottom()); // clear this listener so insets aren't re-applied rootView.setOnApplyWindowInsetsListener(null); return insets.consumeSystemWindowInsets(); } });
@Override @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH) public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) { toolbar.setPadding(toolbar.getPaddingStart() + insets.getSystemWindowInsetLeft(), toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(), toolbar.getPaddingEnd() + insets.getSystemWindowInsetRight(), toolbar.getPaddingBottom()); recyclerView.setPadding(recyclerView.getPaddingStart() + insets.getSystemWindowInsetLeft(), recyclerView.getPaddingTop(), recyclerView.getPaddingEnd() + insets.getSystemWindowInsetRight(), recyclerView.getPaddingBottom() + insets.getSystemWindowInsetBottom()); // clear this listener so insets aren't re-applied rootView.setOnApplyWindowInsetsListener(null); return insets.consumeSystemWindowInsets(); } });
@Override @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH) public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) { toolbar.setPadding(toolbar.getPaddingStart() + insets.getSystemWindowInsetLeft(), toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(), toolbar.getPaddingEnd() + insets.getSystemWindowInsetRight(), toolbar.getPaddingBottom()); bottomBar.setPadding(bottomBar.getPaddingStart() + insets.getSystemWindowInsetLeft(), bottomBar.getPaddingTop(), bottomBar.getPaddingEnd() + insets.getSystemWindowInsetRight(), bottomBar.getPaddingBottom() + insets.getSystemWindowInsetBottom()); // clear this listener so insets aren't re-applied rootView.setOnApplyWindowInsetsListener(null); return insets.consumeSystemWindowInsets(); } });
@Override @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH) public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) { toolbar.setPadding(toolbar.getPaddingStart() + insets.getSystemWindowInsetLeft(), toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(), toolbar.getPaddingEnd() + insets.getSystemWindowInsetRight(), toolbar.getPaddingBottom()); recyclerView.setPadding(recyclerView.getPaddingStart() + insets.getSystemWindowInsetLeft(), recyclerView.getPaddingTop(), recyclerView.getPaddingEnd() + insets.getSystemWindowInsetRight(), recyclerView.getPaddingBottom() + insets.getSystemWindowInsetBottom()); // clear this listener so insets aren't re-applied rootView.setOnApplyWindowInsetsListener(null); return insets.consumeSystemWindowInsets(); } });
rootView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH) @Override
rootView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @Override @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
@Override @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH) public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) { // clear this listener so insets aren't re-applied rootView.setOnApplyWindowInsetsListener(null); toolbar.setPadding(toolbar.getPaddingStart() + insets.getSystemWindowInsetLeft(), toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(), toolbar.getPaddingEnd() + insets.getSystemWindowInsetRight(), toolbar.getPaddingBottom()); actionArea.setPadding(actionArea.getPaddingStart() + insets.getSystemWindowInsetLeft(), actionArea.getPaddingTop(), actionArea.getPaddingEnd() + insets.getSystemWindowInsetRight(), actionArea.getPaddingBottom() + insets.getSystemWindowInsetBottom()); imageView.setPadding(imageView.getPaddingStart() + insets.getSystemWindowInsetLeft(), imageView.getPaddingTop()/* + insets.getSystemWindowInsetTop()*/, imageView.getPaddingEnd() + insets.getSystemWindowInsetRight(), imageView.getPaddingBottom()/* + insets.getSystemWindowInsetBottom()*/); return insets.consumeSystemWindowInsets(); } });
@Override @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH) public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) { toolbar.setPadding(toolbar.getPaddingStart(), toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(), toolbar.getPaddingEnd(), toolbar.getPaddingBottom()); ViewGroup.MarginLayoutParams toolbarParams = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams(); toolbarParams.leftMargin += insets.getSystemWindowInsetLeft(); toolbarParams.rightMargin += insets.getSystemWindowInsetRight(); toolbar.setLayoutParams(toolbarParams); recyclerView.setPadding(recyclerView.getPaddingStart() + insets.getSystemWindowInsetLeft(), recyclerView.getPaddingTop() + insets.getSystemWindowInsetTop(), recyclerView.getPaddingEnd() + insets.getSystemWindowInsetRight(), recyclerView.getPaddingBottom() + insets.getSystemWindowInsetBottom()); fab.setTranslationY(-insets.getSystemWindowInsetBottom()); fab.setTranslationX(-insets.getSystemWindowInsetRight()); rootView.setOnApplyWindowInsetsListener(null); return insets.consumeSystemWindowInsets(); } });
rootView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @Override @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
@Override @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH) public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) { // clear this listener so insets aren't re-applied rootView.setOnApplyWindowInsetsListener(null); Log.d("MainActivity", "onApplyWindowInsets()" + "[" + insets.getSystemWindowInsetLeft() + ", " + insets.getSystemWindowInsetTop() + ", " + insets.getSystemWindowInsetRight() + ", " + insets.getSystemWindowInsetBottom() + "]"); toolbar.setPadding(toolbar.getPaddingStart(), toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(), toolbar.getPaddingEnd(), toolbar.getPaddingBottom()); ViewGroup.MarginLayoutParams toolbarParams = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams(); toolbarParams.leftMargin = insets.getSystemWindowInsetLeft(); toolbarParams.rightMargin = insets.getSystemWindowInsetRight(); toolbar.setLayoutParams(toolbarParams); recyclerView.setPadding(recyclerView.getPaddingStart() + insets.getSystemWindowInsetLeft(), recyclerView.getPaddingTop() + insets.getSystemWindowInsetTop(), recyclerView.getPaddingEnd() + insets.getSystemWindowInsetRight(), recyclerView.getPaddingBottom() + insets.getSystemWindowInsetBottom()); fab.setTranslationY(-insets.getSystemWindowInsetBottom()); fab.setTranslationX(-insets.getSystemWindowInsetRight()); return insets.consumeSystemWindowInsets(); } });
@RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH) @Override public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) { toolbar.setPadding(toolbar.getPaddingStart() /*+ insets.getSystemWindowInsetLeft()*/, toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(), toolbar.getPaddingEnd() /*+ insets.getSystemWindowInsetRight()*/, toolbar.getPaddingBottom()); ViewGroup.MarginLayoutParams toolbarParams = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams(); toolbarParams.leftMargin += insets.getSystemWindowInsetLeft(); toolbarParams.rightMargin += insets.getSystemWindowInsetRight(); toolbar.setLayoutParams(toolbarParams); recyclerView.setPadding(recyclerView.getPaddingStart() + insets.getSystemWindowInsetLeft(), recyclerView.getPaddingTop() + insets.getSystemWindowInsetTop(), recyclerView.getPaddingEnd() + insets.getSystemWindowInsetRight(), recyclerView.getPaddingBottom() + insets.getSystemWindowInsetBottom()); fab.setTranslationY(-insets.getSystemWindowInsetBottom()); fab.setTranslationX(-insets.getSystemWindowInsetRight()); // clear this listener so insets aren't re-applied rootView.setOnApplyWindowInsetsListener(null); return insets.consumeSystemWindowInsets(); } });