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!
I found a solution that works quite well in my project. It consists of 2 behaviors, one for the AppBarLayout and another one for the scrolling container. You can find it on Github here: appbar-snap-behavior
It's quite easy to install it:
compile "com.github.godness84:appbar-snap-behavior:0.1.1"
Remember to add maven { url "https://jitpack.io" }
in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Then:
app:layout_behavior="com.github.godness84.appbarsnapbehavior.AppBarSnapBehavior"
to your AppBarLayoutapp:layout_behavior="com.github.godness84.appbarsnapbehavior.ScrollingViewBehavior"
into your scrolling container.Unfortunately, since the default behavior of the AppBarLayout is replaced, some features are not available anymore (for example AppBarLayout.setExpanded()), but in normal situations it works! Give it a try and let me know.