Common bottom layout in all the tabs of TabHost in Android?

a 夏天 提交于 2019-12-08 03:15:37

问题


I have a TabHost with 4-5 tabs. I want to have a similar bottom for all the tabs. Is there any way we can add a bottom to all the tabs? Or do I need to place the xml code in every layout file.

Please let me know if any one has the solution.

Regards

Sunil


回答1:


The simplest solution would be to use the <include> option in your layout files.

Define the common footer in a layout file all by itself - e.g tab_footer.xml - and then include it into the the other layouts as follows:

<include layout="@layout/tab_footer">

You can find out more about <include> in this post on the Android Developers Blog.

One thing that isn't mentioned in that post: if you want to override any layout parameters when you use <include> make sure you override layout_width and layout_height (even if they're not changing) otherwise your values for other parameters will be silently ignored.



来源:https://stackoverflow.com/questions/2895925/common-bottom-layout-in-all-the-tabs-of-tabhost-in-android

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