The question is published on by Tutorial Guruji team.
I want to implement scroll behavior for Toolbar title as its implemented in Apple Music Android app.
Thank you in advance!
As Piyush said, https://github.com/brucetoo/Android-ObservableScrollView is exactly the library you need for this. This is how you’d go about it
Import the library by going to your app’s Gradle file and pasting this
Make your xml layout and instead of using a standard
ScrollViewto wrap it, use an
ObservableScrollView. Outside of the scroll view, make a toolbar that will host your menu buttons as well as the title i.e. “Library”
In you Java/ Kotlin file, attach a listener to the scroll view by using
listView.setScrollViewCallbacks. Provide an object implementing the
ObservableScrollViewCallbacksinterface as an argument.
In the callback, change the YTranslation and alpha values of the title in your toolbar based on the scroll factor
I don’t have android studio in front of me, so I can’t provide any code, but this is the jist of it.