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!



Recent Posts:




Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.