Basically, I want to change the height of the tabs in actionbars. This questions has been asked several times on stackoverflow, for example:
ActionBar tabs height
I have tried most of the solutions but nothing work, here is my code.
<style name="CustomActionBarTheme" parent="@android:style/Theme.Holo">
<item name="android:scrollHorizontally">false</item>
<item name="android:paddingLeft">0dp</item>
<item name="android:paddingRight">0dp</item>
<item name="android:actionBarSize">80dp</item>
<item name="actionBarSize">80dp</item>
<item name="android:actionBarTabStyle">@style/ActionBarTabStyle</item>
</style>
<style name="ActionBarTabStyle" parent="@android:style/Widget.Holo.ActionBar.TabView">
<item name="android:height">80dp</item>
</style>
Apparently, the code only change the actionbar height, not the tab bar height as I want. Here is the picture for reference:
As you can see, the actionbar on the bottom is higher. But in actionbar mode, the tabs height remain the same.
Why is this happening? Did i miss something??? Thank you in advance :).
Solved, as mention in:
ActionBar with navigation tabs changes height with screen orientation
and
https://code.google.com/p/android/issues/detail?id=41792
Apparently this is a bug from android sdk ... Never though I would encounter a bug like this :(. Hope this help other people.
By setting both the Application theme attribute android:actionBarSize and the ActionBar.TabView style attribute android:minHeight (or height) to 80 dp. A basic example:
<style name="ThemeHoloWithActionBar" parent="android:Theme.Holo.Light">
<item name="android:actionBarTabStyle">@style/ActionBarTabStyle</item>
<item name="android:actionBarSize">80dp</item>
</style>
<style name="ActionBarTabStyle" parent="@android:style/Widget.Holo.ActionBar.TabView">
<item name="android:minHeight">80dp</item>
</style>
Set theme in Manifest:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/ThemeHoloWithActionBar" >
Activity
ActionBar actionbar = getActionBar();
actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionbar.setDisplayShowTitleEnabled(false);
actionbar.setDisplayShowHomeEnabled(false);
ActionBar.Tab tabA = actionbar.newTab().setText("Tab A");
ActionBar.Tab tabB = actionbar.newTab().setText("Tab B");
ActionBar.Tab tabC = actionbar.newTab().setText("Tab C");
tabA.setTabListener(new MyTabsListener());
tabB.setTabListener(new MyTabsListener());
tabC.setTabListener(new MyTabsListener());
actionbar.addTab(tabA);
actionbar.addTab(tabB);
actionbar.addTab(tabC);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With