Nuraiz
Nuraiz

Reputation: 1070

Change Actionbar Tabs Height

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.

Upvotes: 3

Views: 5243

Answers (2)

StefanoM5
StefanoM5

Reputation: 1337

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>

Upvotes: 0

ZhangLei
ZhangLei

Reputation: 413

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>

Upvotes: 1

Related Questions