SubtitleCoordinatorLayoutExample icon indicating copy to clipboard operation
SubtitleCoordinatorLayoutExample copied to clipboard

Suggestion: handle onOffsetChanged better

Open AndroidDeveloperLB opened this issue 10 years ago • 0 comments

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);
}

AndroidDeveloperLB avatar Nov 09 '15 09:11 AndroidDeveloperLB