Search code examples
androidandroid-layoutandroid-actionbarandroid-tabhostandroid-tabs

How to display all the tabs of ActionBar at the same time, like in tabHost


When I add 5 tabs using tabHost, the tabs are shown like this:

|-(tab1)(tab2)(tab3)(tab4)(tab5)-|

But, using ActionBar Tabs, the tabs are shown like this:

|-(    tab1    )(    tab2    )( -|

To view the others tabs, we have to swipe:

|-(    tab1    )(    tab2    )( -|

<-- *swipe* <--
|-ab2    )(    tab3    )(    tab-|

<-- *swipe* <--
|-  )(    tab3    )(    tab4    -|

<-- *swipe* <--
|- )(    tab4    )(    tab5    )-|

How to, using ActionBar Tabs, display the tabs like this:

|-(tab1)(tab2)(tab3)(tab4)(tab5)-|

???


Solution

  • You don't. You do not have that level of control over action bar tabs. Action bar tabs are not even tabs half of the time -- the action bar will covert them into a drop-down list navigation depending upon screen size and orientation.

    Generally speaking, swipeable tabs are the recommended solution, to handle more possible screen sizes.

    That being said, you are welcome to use FragmentTabHost if you absolutely must ensure that all tabs are visible at all times.