Skip to content

Suggestion: handle onOffsetChanged better #4

@AndroidDeveloperLB

Description

@AndroidDeveloperLB

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions