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

后端 未结 10 952
遇见更好的自我
遇见更好的自我 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条回答
  •  滥情空心
    2020-12-28 15:12

    Everyone is giving the code, "Talk is cheap, show me the code" right. 
    I prefer not showing the code this time. 
    I will talk. I do not recommand such a complicated activity.
    

    DrawerLayout and TabLayout are the 2 of major navigation method for android. DrawerLayout and TabLayout shown in a same activity do against the android developement guildline. And if you do so your app will be very hard to use.

    Imagine that, if the user do a right-left swipe, should you swipe gesture the pagerview or the drawerlayout? I see you may apply the swipe gesture to the drawerlayout when the user swipe from the right-egde of the activity, otherwise you may apply the gesture to the pagerview, but how do you make sure the user knows this rule?

    Even the users know how to swipe your activity (users may very make sense nowadays), your app still look very complicated.

    My suggestion is,

     if you have less than 5 main menus, just use tablayout + actionbar, 
     if you have more than 5 main menus, use drawerlayout + actionbar. 
     you don't have to use both navigation in a row, you can still place the important actions to the actionbar right.
    

提交回复
热议问题