Roel
Roel

Reputation: 3096

How to change the color of GUI elements in Android in the whole application?

I have created a Custom style in which I changed the background of the complete App. Now I want to change the light blue colored items to red. I do not want to change each individual view... Is there a simple and fast method to change this just like the background of the App?

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

<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <color name="colorBackground">#A0A0A3</color>
    <color name="windowBackground">#0B2265</color>
    <color name="textColor">#FFFFFF</color>
    <color name="highlight">#ED1B24</color>

    <style name="CustomStyle" parent="android:Theme.Holo">
        <item name="android:windowBackground">@color/windowBackground</item>
        <item name="android:colorBackground">@color/colorBackground</item>
        <item name="android:textColor">@color/textColor</item>

    </style>
</resources>

Colors I want to change

Upvotes: 0

Views: 3243

Answers (3)

Reinier
Reinier

Reputation: 3876

As for the ActionBar and EditText - those are 9-patch drawables that you can replace with your own to change the appearance. For examples, check out this answer for the line beneath the ActionBar and this answer for the EditText.

As for the DatePicker, I'm not quite sure - haven't had to use it yet. I'd suggest checking out the Android source code to figure out where the blue lines come from (e.g. from style attributes or hardcoded). One approach is to open DatePicker.class, see what XML file is loaded to build the layout and from there find any associated styles and drawables. If you find the XML / drawables, copy them to your project, change them to fit your needs, and apply them to (in this case) DatePicker in the same way the Android system does it (as can be seen in the source).

Upvotes: 1

Sprigg
Sprigg

Reputation: 3319

You can't just change a color and everything will change. Most of the UI elements are png graphics, so you have to change all graphics by yourself and create your own theme.

Upvotes: 2

Aerilys
Aerilys

Reputation: 1629

You can create your own theme and apply it to the entire app

See the following link : http://developer.android.com/guide/topics/ui/themes.html

Upvotes: 0

Related Questions