Skip to content

Suggestion: For those that want to make the view scroll away to be shown or hidden #3

Description

@snowpong

Thanks for this example.

Here is a suggestion. Since the normal way for AppBarLayout to behave is to scroll, it could be interesting for the bottom bar to behave the same. To get the view scrolling in and out instead of this animation, we can simply just translate it:

    @Override
    public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, View child, View target, int dx, int dy, int[] consumed) {
        float oldTranslation = child.getTranslationY();
        float newTranslation = oldTranslation + dy;
        if (newTranslation > child.getHeight()) {
            child.setTranslationY(child.getHeight());
        } else if (newTranslation < 0) {
            child.setTranslationY(0);
        } else {
            child.setTranslationY(newTranslation);
        }
    }

A small gist of the same https://gist.github.com/snowpong/2a9eaf80d814c6938d55

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions