简体   繁体   中英

Using different layouts under a Toolbar

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM