片段和导航抽屉的不同工具栏 [英] Different toolbar for fragments and Navigation Drawer
问题描述
请向我解释...我的Activity
中有导航抽屉,它与Toolbar
同步(如ActionBar
).活动只有很少的片段,而在不同的片段中,我需要使用不同的AppBar
模式(一个视差,另一个简单).因此,我认为我应该在每个带有AppBar和内容的frament中设置CoordinatorLayout
.
但是如何替换新的最后一个工具栏以保存与Drawer的同步?还是这是错误的方式,我需要另做些?
Please, explain to me... I have Navigation Drawer in my Activity
and it syncs with Toolbar
(like ActionBar
). Activity has few fragments and in different fragments I need to use different AppBar
modes (parallax in one, simple in another). So, I think that I should set CoordinatorLayout
in each frament with AppBar and content.
But how I can replace last toolbar on new to save synchronization with Drawer? Or it's wrong way and I need make it some else?
推荐答案
如果您将DrawerLayout
和NavigationView
用于导航抽屉,根据我的最佳解决方案是对每个导航栏使用单独的DrawerLayout
片段布局,并对每个片段使用DrawerLayout
主体中的AppBarLayout
.
If you are using DrawerLayout
and NavigationView
for your navigation drawer, best solution according to me would be to use individual DrawerLayout
for each of the fragment layouts and use the AppBarLayout
in the body of the DrawerLayout
differently for each of the fragments.
这篇关于片段和导航抽屉的不同工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!