片段和导航抽屉的不同工具栏 [英] Different toolbar for fragments and Navigation Drawer

查看:82
本文介绍了片段和导航抽屉的不同工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请向我解释...我的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?

推荐答案

如果您将DrawerLayoutNavigationView用于导航抽屉,根据我的最佳解决方案是对每个导航栏使用单独的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆