问题
In my app, I am using a android.support.v7.widget.Toolbar
and I have various fragments with different items it the toolbar.
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.
回答1:
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.
来源:https://stackoverflow.com/questions/31426883/using-different-layouts-under-a-toolbar