工具栏下,使用不同的布局 [英] Using different layouts under a Toolbar
问题描述
在我的应用程序,我使用的是 android.support.v7.widget.Toolbar
和我有不同的项目它在工具栏的各种片段。
In my app, I am using a android.support.v7.widget.Toolbar
and I have various fragments with different items it the toolbar.
什么是实现正确的方法是什么?
我应该使用不同的 android.support.v7.widget.Toolbar
每个片段与它的子视图,或者我应该使用一个主工具栏和隐藏/做出可见的元素?后者似乎凌乱和ungly。
What is the correct way to implement that?
Should I use a different android.support.v7.widget.Toolbar
for each fragment with it's child views, or should I use one main toolbar and hide/make visible elements? The latter seems messy and ungly.
推荐答案
工具栏基本上是一个简单的ViewGroup,所以你可以把它这种方式。您可以在工具栏创建一个片段持有人,然后就你想要的任何片段取代它。
ToolBar is basically just a simple ViewGroup so you can treat it this way. You can create a fragment holder in the ToolBar and then just replace it with any Fragment you want.
您也可以把根据你的逻辑中有一个隐藏/显示他们不同的看法。无论哪种方式是发现,取决于你的应用需求。
You can also put different views in it a hide/unhide them according to your logic. Either way is find, depends on your app needs.
这篇关于工具栏下,使用不同的布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!