Android custom action bar with different styles example

Android action bar by default comes with dark or Light theme, programmatically  styles can be changed by modifying styles.xml of values folder.

Note: We are using v7 appcompat support library, it support action bar in all the devices from API 7 onward.

To get Dark action bar in all the version of devices, just go to styles.xml in all folder and update parent theme to “Theme.AppCompat.Light.DarkActionBar” i.e

<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
</style>
dark_actionbar_image
Dark action bar after changing styles

For Light action bar, update “Theme.AppCompat.Light” as parent theme in styles.xml in all the folder.

<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
</style>
Light_actionbar_image
Light action bar after changing styles

To style action bar with custom color, visit actionbarstylegenerator & get the styles. Preview of styles will be visible. Many options can be customized like tabs, menus, background colors etc…

action_bar_style_generator
Android Action Bar Style Generator preview

Once its fully customized download & update the application folder accordingly.

values_folders_android
Folders after updating the Styles

In manifest file, update the application theme name. Here Greenactionbar was the style name provided for generating style

  <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.Greenactionbar" >
styled_action_bar
Green action bar