How to change Android Titlebar theme color from Purple


When you create your first ever application or select a new project in Android Studio you must have seen that the default color theme of the Titlebar (Toolbar) is purple. If you want to change the color theme, follow the below steps,

  1. Go to res folder,
  2. Now go to values -> colors.xml
  3. Now add the new colors that you want, example,
    <color name="grey">#888888
  4. Now go to themes folder,
  5. Open themes.xml file
  6. Change the colorPrimary value to @color/grey
    <resources xmlns:tools="http://schemas.android.com/tools">
        <style name="Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
            <item name="colorPrimary">@color/grey</item>
            <item name="colorPrimaryVariant">@color/purple_700</item>
            <item name="colorOnPrimary">@color/white</item>
            <item name="colorSecondary">@color/teal_200</item>
            <item name="colorSecondaryVariant">@color/teal_700</item>
            <item name="colorOnSecondary">@color/black</item>
            <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
        </style>
    </resources>
  7. Launch the app in emulator to see the changes.
Change Android App Titlebar color from purple
Change Android App Titlebar color from purple

Note: You can change the other theme colors here such as statusBarColor, colorSecondary, colorSecondaryVariant and so on in the same way!

Happy Coding!!



Have Questions? Post them here!


















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap