How to customize Action Bar Style?

10,798

Solution 1

Just find proper icons for your actionbar and customize it... and then make changes in your...

You Can Do Following For Changing Icons Of Actionbar

style.xml

<style name="Widget.ActionButton.Overflow" parent="@android:style/Widget.Holo.ActionButton.Overflow">
    <item name="android:src">@drawable/ic_action_overflow</item>
</style>

<style name="Your.Theme" parent="@android:style/Theme.Holo.Light.DarkActionBar">
    <item name="android:actionOverflowButtonStyle">@style/Widget.ActionButton.Overflow</item>

    <item name="android:homeAsUpIndicator">@drawable/my_fancy_up_indicator</item>
</style>

Solution 2

check out this page on android help https://developer.android.com/training/basics/actionbar/styling.html

When supporting Android 3.0 and higher only,

you can define the action bar's background like this: res/values/themes.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- the theme applied to the application or activity -->
    <style name="CustomActionBarTheme"
           parent="@android:style/Theme.Holo.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
    </style>

    <!-- ActionBar styles -->
    <style name="MyActionBar"
           parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
        <item name="android:background">@drawable/actionbar_background</item>
    </style>
</resources>

Then apply your theme to your entire app or individual activities:

<application android:theme="@style/CustomActionBarTheme" ... />

For Android 2.1 and higher

When using the Support Library, the same theme as above must instead look like this:

res/values/themes.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- the theme applied to the application or activity -->
    <style name="CustomActionBarTheme"
           parent="@style/Theme.AppCompat.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/MyActionBar</item>

        <!-- Support library compatibility -->
        <item name="actionBarStyle">@style/MyActionBar</item>
    </style>

    <!-- ActionBar styles -->
    <style name="MyActionBar"
           parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="android:background">@drawable/actionbar_background</item>

        <!-- Support library compatibility -->
        <item name="background">@drawable/actionbar_background</item>
    </style>
</resources>

Then apply your theme to your entire app or individual activities:

<application android:theme="@style/CustomActionBarTheme" ... />
Share:
10,798
user3458008
Author by

user3458008

Updated on July 20, 2022

Comments

  • user3458008
    user3458008 almost 2 years

    How to change the color of Action Bar Back Button and Action bar Menu Icon(Image attached). I have the following style code(below), using which I customized the Text but I'm not able to completely customize the Action Bar.

    Below is the Style code which I have used :

    <style name="MyCustomTheme" parent="Theme.Sherlock.Light">
    
         <item name="actionBarStyle">@style/ActionBar</item>
    
         <item name="android:actionBarStyle">@style/ActionBar</item>
    
         </style>
    
     <style name="ActionBar" parent="Widget.Sherlock.ActionBar">
            <item name="background">@drawable/bg_header</item> -----------(1)
            <item name="android:background">@drawable/bg_header</item>
    
            <item name="android:titleTextStyle">@style/customTextAppearance.Sherlock.Widget.ActionBar.Title</item> ----(2)
            <item name="titleTextStyle">@style/customTextAppearance.Sherlock.Widget.ActionBar.Title</item>
             <item name="android:homeAsUpIndicator">@style/customTextAppearance.Sherlock.Widget.ActionBar.Title</item>
        </style>
    
    
     <style name="customTextAppearance.Sherlock.Widget.ActionBar.Title" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
            <item name="android:textSize">18dp</item>
            <item name="android:textColor">#ffffff</item>
            <item name="android:shadowColor">#ffffff</item>
            <item name="android:shadowDy">3</item>
            <item name="android:textStyle">bold</item>
    
    </style>
    

    Your help will be appreciated, Thank you. Screen Shot

  • Ankita
    Ankita over 9 years
    I just gave you a overview about how to get a custom bar for the different versions.. anyways glad that you got your answer.