Search code examples
androidandroid-tabhost

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


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


Solution

  • 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.