How to change action bar size

The question:

I would like to change the action bar size. I have tried the following coding.

<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/CustomActionBar</item>
<style name="CustomActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <!--  <item name="android:background">@drawable/action_bar_style</item> -->
    <item name="android:actionBarSize">15dp</item>
    <item name="android:background">@drawable/header_bar</item>

But the action bar size didn’t change. Is there another way? I am using api level 11.


The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

Use height attribute, actionBarSize if for something else.

<item name="android:height">@dimen/bar_height</item>


From source code of ActionBar:

mContentHeight = a.getLayoutDimension(R.styleable.ActionBar_height, 0);

We can see that R.styleable.ActionBar_height is being used for height. Stylable property names are generated as component_attribute (If you have ever used a custom stylable view, you’d have notice this). Hence, Actionbar is the name of component and height is the name of the attribute to use. Since this is a system attribute, hence defined under android namespace.

Update Dec-2014:

AppCompat library is now provided to extend support for latest ActionBar (or Toolbar) and theme support to old android versions. Below is an example of such an application theme /res/values/styles.xml:


    <!-- Application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light">

        <!-- Main theme colors -->
        <!--   your app branding color for the app bar -->
        <item name="colorPrimary">@color/primary</item>

        <!--   darker variant for the status bar and contextual app bars -->
        <item name="colorPrimaryDark">@color/primary_dark</item>

        <!--   theme UI controls like checkboxes and text fields -->
        <!--   native widgets will now be "tinted" with accent color -->
        <item name="colorAccent">@color/accent</item>

        <!--Action bar style-->
        <item name="android:actionBarStyle">@style/AppTheme.ActionBar</item>
        <item name="actionBarStyle">@style/AppTheme.ActionBar</item>


    <style name="AppTheme.ActionBar" parent="Widget.AppCompat.Light.ActionBar">
        <item name="android:titleTextStyle">@style/AppTheme.ActionBar.TitleText</item>
        <item name="titleTextStyle">@style/AppTheme.ActionBar.TitleText</item>
        <item name="android:height">@dimen/bar_height</item>
        <item name="height">@dimen/bar_height</item>

    <style name="AppTheme.ActionBar.TitleText" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
        <item name="android:textSize">@dimen/bar_text_size</item>
        <item name="android:textColor">@color/bar_text_color</item>

This style can now be set as app theme by using android:theme="@style/AppTheme" in <application> tag of the AndroidManifest.xml.

Note the use of duplicate entries

<item name="android:actionBarStyle">
<item name="actionBarStyle">

The ones without android namespace are there for supporting both compatibility library and native attributes.Some of these attributes didn’t exist under android namespace on older versions and belong to support library.

In some other places, you’ll need to use app namespace (xmlns:app=""), for example app:showAsAction="always" in menu xml files.

Update Apr 2015

AppCompat Library v22 is also available. Read through the article to know what’s new.

Method 2

Simply put actionBarSize item under MyTheme style, like this:

<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarSize">15dp</item>
    <item name="actionBarSize">15dp</item>


In R.styleable we see that R.styleable.Theme_actionBarSize is a styleable attribute defined at Theme level.

Also, from source code res/values/styles.xml we see how actionBarSize is used to set height:

<style name="Widget.ActionBar">
    <item name="android:height">?android:attr/actionBarSize</item>

Method 3

Add this to the custom theme style XML that you are referencing from your manifest file:

<item name="android:windowTitleSize">58dip</item>

For instance if your manifest file looks something like this:

        **android:theme="@style/AppTheme"** >

Your theme style should be -at least- like this:

<!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">            
        <item name="android:windowTitleSize">54dip</item>

Method 4

Make sure to add S.D.’s code to styles.xml and then add


to the <application> element in the main manifest. (I’m a noob and it took me about 2 hours to find that out.)

Method 5

S.D.’s solution does not work for me.
I used AppCompat v-21 library in my case.
And I just add


to my layout file and it works.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment