Android : How to change ActionBar/ ToolBar color

Points To Remember

You can just override the primary_material_dark in the colorx.xml file in values folder.

How to change ActionBar/ ToolBar color


  • We will create a new file colors.xmlif it does not exist.
  • Override the Primary color of the theme Theme.AppCompat.Light.DarkActionBar
  • See the results


<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="primary_material_dark">#1B5891</color>
</resources>

Your styles.xml file may look like the following

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
    </style>

</resources>

and the AndroidManifest.xml may look like following

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.ekiras.demo" >

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

No comments :

Post a Comment