I just had a look at Ice Cream Sandwich source code, because I am trying to port the Holo Theme to all pre-4.0 devices.
I used a lot of usefull tools:
Action Bar: ActionBarSherlock
ICS Background:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="270"
android:startColor="#ff020202"
android:endColor="#ff272D33d"
android:type="linear" />
</shape>
and till now, everything is just awesome!!!
I am now trying to create a button, but cannot find the correct background:
Following source: https://github.com/android/platform_frameworks_base/blob/master/core/res/res/drawable/btn_default.xml
I tried 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" />
And I copied every .9.png file into my drawable folder.
But Unfortunately, all these drawable seems rather white and I cannot get something similar to this button:
Here are all resource:
btn_default_normal_holo_dark.9.png
btn_default_normal_holo_light.9.png
btn_default_normal.9.png
A drawable resource is a general concept for a graphic that can be drawn to the screen and which you can retrieve with APIs such as getDrawable(int) or apply to another XML resource with attributes such as android:drawable and android:icon . There are several different types of drawables: Bitmap File.
Drawable myImage = ResourcesCompat. getDrawable(res, R. drawable. my_image, null);
Right Click on Drawable folder -> New -> Drawable Resource File , will create a XML file inside the Drawable folder.
I had to choose Holo Dark theme:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/btn_default_normal_holo_dark" android:state_enabled="true" android:state_window_focused="false"/>
<item android:drawable="@drawable/btn_default_disabled_holo_dark" android:state_enabled="false" android:state_window_focused="false"/>
<item android:drawable="@drawable/btn_default_pressed_holo_dark" android:state_pressed="true"/>
<item android:drawable="@drawable/btn_default_focused_holo_dark" android:state_enabled="true" android:state_focused="true"/>
<item android:drawable="@drawable/btn_default_normal_holo_dark" android:state_enabled="true"/>
<item android:drawable="@drawable/btn_default_disabled_focused_holo_dark" android:state_focused="true"/>
<item android:drawable="@drawable/btn_default_disabled_holo_dark"/>
</selector>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With