I have made the snapping app bar like this:
Please note that when the scroll is left in the middle(i.e the title is half visible, then the app bar snaps automatically)
In case of google play this is what the snap looks like:
Now, I want the snap to work like the one in google play. Which is that when the snap occurs, then only the app bar should snap and the recycler view should not move. It would be better if the solution supported pre lollipop devices too.
Thanks!
See my library Retractable Toolbar
You have to add this on build.gradle
compile 'it.michelelacorte.retractabletoolbar:library:1.0.0'
Than in your MainActivity.java
use RecyclerView
and this:
RetractableToolbarUtil.ShowHideToolbarOnScrollingListener showHideToolbarListener;
recyclerView.addOnScrollListener(showHideToolbarListener = new RetractableToolbarUtil.ShowHideToolbarOnScrollingListener(toolbar));
if (savedInstanceState != null) {
showHideToolbarListener.onRestoreInstanceState((RetractableToolbarUtil.ShowHideToolbarOnScrollingListener.State) savedInstanceState
.getParcelable(RetractableToolbarUtil.ShowHideToolbarOnScrollingListener.SHOW_HIDE_TOOLBAR_LISTENER_STATE));
}
This is effect:
EDIT:
Since 23.1.0 design library you can add |snap
attribute to your ToolBar layout:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways|snap />
It should be more or less what you are looking.
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