SubtitleCoordinatorLayoutExample
SubtitleCoordinatorLayoutExample copied to clipboard
Suggestion: handle onOffsetChanged better
It seems it won't show the title&subtitle if the toolbar is currently showing them, after orientation change.
I suggest to make it much shorter, and ditch the field used for it:
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int offset) {
int maxScroll = appBarLayout.getTotalScrollRange();
float percentage = (float) Math.abs(offset) / (float) maxScroll;
toolbarHeaderView.setVisibility(percentage < 1f ? View.GONE : View.VISIBLE);
}