Question: Where can I find default styles xml with hexadecimal codes of colors?
I'm looking for Style 'buttonStyle' and other default styles witch affect aspects like TextViews, Buttons etc (if you dont change the style of aspect)
I looked up in <instalation_folder>\android-sdk\platforms\android-<versio>\data\res\values
and <instalation_folder>\android-sdk\platforms\android-<version>\data\res\colors
but I didn't actually find what I was looking for.
Hope my question is clear.
Due to low reputation I cant answer this question yet. Here is answer
Answer
With a bit of googling I found 'buttonStyle' is actually 'Widget.Button' - Styling Android With Defaults
This is how it works:
- As I said 'buttonStyle' style is accualy 'Widget.Button' style defined in
\android-sdk\platforms\android-<version>\data\res\values\styles.xml
. Background is set to:@android:drawable/btn_default
\android-sdk\platforms\android-<version>\data\res\drawable\btn_default.xml
defines background color of button as selector. Color actually depends on button's state. Default color is set to@drawable/btn_default_normal
- With a bit of searching I found, that btn_default_normal is png image located in
\android-sdk\platforms\android-<version>\data\res\drawable-mdpi
I find it a bit confusing, but I hope it will help someone, maybe...
You can find default styles of android widgets when you declare in XML:
For example this is style of default button:
background of default button:
You can get the default color with the help of any graphics editor: path to default button NinePatch ..\android-sdk\platforms\android-13\data\res\drawable-hdpi
Understanding how Android styles do work can be a little bit messy.
I will try to explain how the basic work flow would be, based on an example.
Let's assume you want to know what the default background for buttons is. This can be either a simple color (unlikely) or a drawable (there are many different types of drawables).
Android has Themes. A theme basically defines which style is applied to which widget. Therefore, our first step is to find the default android theme.
You find it under
android-sdk\platforms\android-15\data\res\values\themes.xml
In this theme file, search for
button
.You will find something like this:
This means that the theme applies the style
Widget.Button
to buttons.Ok, now let's find the style
Widget.Button
.All default Android style are defined in the file
android-sdk\platforms\android-15\data\res\values\styles.xml
Now search for
Widget.Button
You will find something like this:
The interesting line is:
<item name="android:background">@android:drawable/btn_default</item>
This means that there is a drawable called
btn_default
set as button background.Now we need to find a file named
btn_default.*
in one of the drawable folders underandroid-sdk\platforms\android-15\data\res
.This can be either an image (very unlikely) or a xml file like
btn_default.xml
.After a little bit searching you will find the file
android-sdk\platforms\android-15\data\res\drawable\btn_default.xml
It contains something like this:
Now you have to understand that this is a selector drawable (one of the many drawable types). This selector chooses different backgrounds, based on the buttons state. For example, if the buttons is pressed, it has a different background.
No let's look at the default state.
<item android:state_enabled="true" android:drawable="@drawable/btn_default_normal" />
It applies a drawable called
btn_default_normal
.Now we need to find this drawable.
Again, we need to find a file named
btn_default_normal.*
in one of the drawable folders underandroid-sdk\platforms\android-15\data\res
.This can be again either an image or a xml file like
btn_default_normal.xml
.You will find multiple files called 'btn_default_normal.9.png' in different drawable folders for different resolutions.
:) Now you know that
btn_default_normal.9.png
is set as button background.