Using different layouts under a Toolbar

北慕城南 提交于 2019-12-11 09:25:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!