Android Button Background Selector
I want to use the following selector for button: -
Solution 1:
I find it best to separate the state logic and drawable code. From the Android docs: http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList
<?xml version="1.0" encoding="utf-8"?><selectorxmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:state_pressed="true"android:drawable="@drawable/button_pressed" /><!-- pressed --><itemandroid:state_focused="true"android:drawable="@drawable/button_focused" /><!-- focused --><itemandroid:state_hovered="true"android:drawable="@drawable/button_focused" /><!-- hovered --><itemandroid:drawable="@drawable/button_normal" /><!-- default --></selector>
I would then put the code to give rounded corners in a separate drawable XML. I'm not sure if you can even do such things directly in a selector
.
Post a Comment for "Android Button Background Selector"