Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ICS-looking buttons: which drawable do I have to choose in ICS SDK?

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:

http://cdn3.staztic.com/screenshots/combourkekitchentimer-2-0.jpg

Here are all resource:

btn_default_normal_holo_dark.9.png

enter image description here

btn_default_normal_holo_light.9.png

enter image description here

btn_default_normal.9.png

enter image description here

like image 670
Waza_Be Avatar asked Feb 25 '12 10:02

Waza_Be


People also ask

What is a drawable?

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.

Which function is used to load a drawable image resource?

Drawable myImage = ResourcesCompat. getDrawable(res, R. drawable. my_image, null);

How do I create an XML file in a drawable folder?

Right Click on Drawable folder -> New -> Drawable Resource File , will create a XML file inside the Drawable folder.


1 Answers

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>
like image 176
Waza_Be Avatar answered Oct 08 '22 20:10

Waza_Be