Skip to content
Droid Bits

Droid Bits

Notes on Android Development

Find Droid Bits

Tag: actionBarStyle

Customise ActionBar

Categories: Android Generic, XML AndroidTags: ActionBar, actionBarStyle, AndroidManifest, AndroidManifest.xml, AppTheme, displayOptions, showHome, style, theme, useLogo

Customise the appearance of the action bar at the top of your app.

In our styles.xml file:

    <style name="ActionBar.Solid.MyApp.NoTitle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse"> // Create new style using existing template
        <item name="displayOptions">useLogo|showHome</item> // Add options
        <item name="logo">@drawable/ic_logo</item> // provide resources according to options selected
    </style>

    <style name="AppTheme.MyTheme" parent="@style/AppTheme"> // Create a style that uses the AppBar customisation above
        <item name="actionBarStyle">@style/ActionBar.Solid.MyApp.NoTitle</item>
    </style>

In AndroidManifest.xml apply the style to the Activity whose appearance you wish to change:

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.MyTheme" // Point to your custom theme
            android:launchMode="singleTop">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>