Prevent CollapsingToolbarLayout collapse if not needed

To implement such behaviour in Cheesesquare example just modify android:layout_height param of the NestedScrollView to wrap_content.
It will prevent scrolling by content if it is small enough to fit on the screen.

And to prevent scrolling by CollapsingToolbarLayout you should programmatically set layout_scrollFlags parameter to the AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP value.

Here described how you can do this.

Leave a Comment