QuickReturnFooterSample icon indicating copy to clipboard operation
QuickReturnFooterSample copied to clipboard

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

Open snowpong opened this issue 10 years ago • 0 comments

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

snowpong avatar Dec 11 '15 14:12 snowpong