I am using CollapsingToolBarLayout
alongside with AppBarLayout
and CoordinatorLayout
, and they are working Fine altogether. I set my Toolbar
to be fixed when I scroll up, I want to know if there is a way to change the title text of the Toolbar, when CollapsingToolBarLayout
it is collapsed.
Wrapping up, I want two different titles when scrolled and when expanded.
Thank you all in advance
This solution works perfectly for me to detect
AppBarLayout
collapsed or expanded.Used
addOnOffsetChangedListener
on theAppBarLayout
.I share the full implementation, based on @Frodio Beggins and @Nifhel code:
And then you can use it:
Hook a
OnOffsetChangedListener
to yourAppBarLayout
. When theverticalOffset
reaches 0 or less than theToolbar
height, it means that CollapsingToolbarLayout has collapsed, otherwise it is expanding or expanded.If you are using CollapsingToolBarLayout you can put this
This solution is working for me:
Use addOnOffsetChangedListener on the AppBarLayout.