Reputation: 3561
How can i archive a Tab layout like this in Android ? The Tab Navigation is part of that Main ActionBar and is not below. PS: Im using ActionBar Sherlock
At the moment is just do:
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
But i want a look like this:
Thanks for help, Kitesurfer
Upvotes: 5
Views: 2701
Reputation: 5901
Try this. This implements a method that will let you select whether you want the tabs in a separate row or in the top row, regardless of screen orientation.
For those who are using this code with the native ActionBar, simply omit the if (actionBar instanceof ActionBarWrapper)
and the block underneath it.
Bear in mind, though, that this is somewhat of a hack and might break in future Android versions.
Upvotes: 0
Reputation: 4258
From this thread. On the topic of overriding the Action Bar tab functionality.
Jake Wharton
I am obligated to tell you this is probably a Bad Idea™ and I don't recommend it. When you fight the platform you almost always end up losing.
I am inclined to agree about fighting the platform. Instead I opted to abandon the stock tab navigation (from both the android platform and ABS library) and instead wrote a layout that looks basically the same as the tabs, and used it as a custom view, applying it using ActionBar.setCustomView(View)
and ActionBar.setDisplayShowCustomEnabled(true)
methods.
This uses the ActionBar api in the standard way (ie. Not fighting the platform) and, as is pointed out in that thread, the tab view is simply a LinearLayout
.
Upvotes: 0
Reputation: 72673
I don't recommend doing this but you could override the ActionBar and ABS styles:
<bool name="abs__action_bar_embed_tabs">false</bool> //for ActionBarSherlock
<bool name="action_bar_embed_tabs">false</bool> //for default ActionBar
Upvotes: 4
Reputation: 2804
Tab will be displayed in actions bar but only if action bar has space. When you are in landscape mode your tabs will move to action bar because in landscape mode action bar has more room.
Upvotes: 3