3

I've been trying to change the height of tabs below action bar in Android. I have searched a lot for this and tried many solutions like setting Themes to application in manifest and many more. Below is the one of the few themes which I have applied but no success.

<style name="CustomActionBarTheme" parent="@android:style/Theme.Holo">
        <item name="android:actionBarTabStyle">@style/ActionBarTabStyle</item>
        <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>
</style>

and I have also tried this one:

<style name="Widget.Holo.Tab" parent="@android:style/Widget.Holo.Light.ActionBar.TabView">
    <item name="android:height">200dp</item>
</style>

<style name="MyTabTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarTabStyle">@style/Widget.Holo.Tab</item>
</style>

I want to add an icon and text below icon. Kindly help me to resolve this.

Thanks in advance.

Nuraiz
  • 1,060
  • 6
  • 17
  • 35
  • have you try `android:minHeigh` in `Widget.Holo.Tab`? – Shayan Pourvatan Feb 18 '14 at 04:59
  • Thanks for your reply. Yes I have tried every thing possible and nothing works for me. If you have any example code please share. – Nuraiz Feb 18 '14 at 05:32
  • i answer same question on http://stackoverflow.com/questions/21110322/how-to-set-height-of-actionbar-tabs-for-android/21110744#21110744 but i think so that's a bug from android `sdk`. – Shayan Pourvatan Feb 18 '14 at 05:35

2 Answers2

1

Seems like the height of Tab has to equal to the height of ActionBar. Try to change the height of Tab from 200 dp to 80 dp or change the height of ActionBar from 80 dp to 200 dp. Although this might not be your expected answer.

<!--Start Theme custom action bar theme -->
<style name="LeActionBarTheme"
    parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <item name="android:actionBarTabStyle">@style/MyActionBarTab</item>
    <item name="android:actionBarTabTextStyle">@style/MyActionBarTabText</item>
    <item name="android:actionBarSize">60dp</item>
    <!-- Support library compatibility -->
    <item name="actionBarStyle">@style/MyActionBar</item>
    <item name="actionBarTabStyle">@style/MyActionBarTab</item>
    <item name="actionBarTabTextStyle">@style/MyActionBarTabText</item>
    <item name="actionBarSize">60dp</item>
</style>

<!-- ActionBarTab Styles -->
<style name="MyActionBarTab"
    parent="@style/Widget.AppCompat.ActionBar.TabView">
    <item name="android:height">60dp</item>
</style>
ZhangLei
  • 393
  • 1
  • 7
  • 17
  • Thanks @ZhangLei but it did not work. any code snippet? – Nuraiz Feb 18 '14 at 05:33
  • Thanks for code, but many things are missing in it like styles you added for tab text, actionbar and ActionBarTab and alos parent style is not working. – Nuraiz Feb 18 '14 at 05:56
  • Those styles not attached have nothing to do with this problem. If your app is supporting 3.0 and above only, you do not have to use the AppCompat in support v7. And, I dont think there is any difference between your code and mine if you changed the height to a same parameter. – ZhangLei Feb 18 '14 at 07:53
0

You can use 3 value for set Tab's dimensions:

<style name="ActionBar.Solid.Mg_style" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">

    <item name="android:actionBarSize">150dp</item>
    <item name="android:height">150dp</item>
    <item name="android:width">150dp</item>

</style>

But you need to include ActionBar.Solid.Mg_style in your style:

<style name="AppTheme" parent="Theme_Mg_style">            
    <item name="android:windowTitleSize">54dip</item>
</style>

<style name="Theme_Mg_style" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/ActionBar.Solid.Mg_style</item>

StefanoM5
  • 1,327
  • 1
  • 24
  • 34