1

I am trying to customize background and color of Title bar. I have seen many example on android site and stack overflow but nothing worked out for me.

In examples they are adding new elements in title bar but i want to customize existing title bar.

I do not want to change anything else. I only want to change background color and font color of text.

Paul Ratazzi
  • 6,289
  • 3
  • 38
  • 50
employeegts
  • 144
  • 2
  • 13
  • Possible duplicate of [Set title background color](http://stackoverflow.com/questions/2251714/set-title-background-color). – jww Dec 01 '14 at 03:42
  • Try this (http://stackoverflow.com/questions/5753223/create-custom-titlebar-in-android) – user3300511 Dec 01 '14 at 03:49
  • I have already seen that example and here my question is why we need to create new mytitle.xml because we are only trying to change background and will it work on other pages of the APP? – employeegts Dec 01 '14 at 03:50

1 Answers1

4

If you are using Android Lollipop (api 21+), you can edit the "styles21.xml" (in the res directory) code and add the following:

<?xml version="1.0" encoding="utf-8"?>

<resources>
    <style name="AppTheme" parent="android:Theme.Material">
        <!-- Customize your theme using Material Design here. -->
        <!-- Title Bar color here -->
        <item name="android:colorPrimary">#YOUR_COLOR_HERE</item>
        <!-- Background color here -->
        <item name="android:windowBackground">#YOUR_COLOR_HERE</item>
    </style>
</resources>

For more information see Google's "Using the Material Theme" here.

This XML code will work throughout the whole app (each different view) unless otherwise specified.

I hope this is what you are looking for!

Community
  • 1
  • 1
Bobby
  • 1,416
  • 1
  • 17
  • 30
  • how to decide parent means which is my parent? – employeegts Dec 01 '14 at 04:11
  • The parent is which theme you wish to use. To see more information about themes please visit the link in my answer. (There are 3 different themes available) – Bobby Dec 01 '14 at 04:15