How to make a collapsible toolbar in android automatically collapse/expand when the vertical offset goes beyond a specific threshold?
As in, if the vertical offset is past the half-point of
you can use the "snap" flag like below:
Using this option will determine what to do when a view only has been partially reduced. If scrolling ends and the view size has been reduced to less than 50% of its original, then this view to return to its original size. If the size is greater than 50% of its sized, it will disappear completely.
You can read more about scrolling flags of CollapsingToolbarLayout here https://guides.codepath.com/android/Handling-Scrolls-with-CoordinatorLayout