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-sdkplatformsandroid-15data
esvalueshemes.xml
In this theme file, search for button
.
You will find something like this:
<!-- Button styles -->
<item name="buttonStyle">@android:style/Widget.Button</item>
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-sdkplatformsandroid-15data
esvaluesstyles.xml
Now search for Widget.Button
You will find something like this:
<style name="Widget.Button">
<item name="android:background">@android:drawable/btn_default</item>
<item name="android:focusable">true</item>
<item name="android:clickable">true</item>
<item name="android:textAppearance">?android:attr/textAppearanceSmallInverse</item>
<item name="android:textColor">@android:color/primary_text_light</item>
<item name="android:gravity">center_vertical|center_horizontal</item>
</style>
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 under android-sdkplatformsandroid-15data
es
.
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-sdkplatformsandroid-15data
esdrawabletn_default.xml
It contains something like this:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/btn_default_normal" />
<item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/btn_default_normal_disable" />
<item android:state_pressed="true" android:drawable="@drawable/btn_default_pressed" />
<item android:state_focused="true" android:state_enabled="true" android:drawable="@drawable/btn_default_selected" />
<item android:state_enabled="true" android:drawable="@drawable/btn_default_normal" />
<item android:state_focused="true" android:drawable="@drawable/btn_default_normal_disable_focused" />
<item android:drawable="@drawable/btn_default_normal_disable" />
</selector>
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 under android-sdkplatformsandroid-15data
es
.
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.