Android Toolbar + Tab Layout + Drawer, Hide toolbar when scrolling and take TabLayout to the top

后端 未结 10 937
遇见更好的自我
遇见更好的自我 2020-12-28 14:41

I have activity which has drawer attached to it. Each menu of the drawer is a fragment, and under one of the menu I have a fragment with TabLayout, and each tab

10条回答
  •  -上瘾入骨i
    2020-12-28 15:20

    As far as I know there is nothing build in that does this for you. However you could have a look at the Google IO sourcecode, especially the BaseActivity. Search for "auto hide" or look at onMainContentScrolled

    In order to hide the Toolbar your can just do something like this:

    toolbar.animate().translationY(-toolbar.getBottom()).setInterpolator(new AccelerateInterpolator()).start();
    

    If you want to show it again you call:

    toolbar.animate().translationY(0).setInterpolator(new DecelerateInterpolator()).start();
    

    Found here: android lollipop toolbar: how to hide/show the toolbar while scrolling?

提交回复
热议问题