I would like to keep this layout on specific action:
Nowadays, I can collapse or expand this CoordinatorLayout
by performing swipe on it. I want to block this behavior.
I assume your list is using a RecyclerView
.
You can turn off nested scrolling on your RecyclerView
which will disable the toolbar collapse:
recyclerView.setNestedScrollingEnabled(false);
You can lock the toolbar by clearing the scroll flags:
CollapsingToolbarLayout toolbar = findViewById(R.id.collapsingToolbar); // or however you need to do it for your code
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
params.setScrollFlags(0); // clear all scroll flags
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With