Staff support for a button (resource handling) in Android?

I achieved this in order to preserve the state of the button using the XML selector component. See, for example, a code snippet.

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <!--  Non focused states 
  -->
    <item android:state_focused="false" android:state_selected="false"
        android:state_pressed="false" android:drawable="@drawable/back_arrow_normal" />
    <item android:state_focused="false" android:state_selected="true"
        android:state_pressed="false" android:drawable="@drawable/back_arrow_hover" />
    <!--  Focused states 
  -->
    <item android:state_focused="true" android:state_selected="false"
        android:state_pressed="false" android:drawable="@drawable/back_arrow_hover" />
    <item android:state_focused="true" android:state_selected="true"
        android:state_pressed="false" android:drawable="@drawable/back_arrow_hover" />
    <!--  Pressed 
  -->
    <item android:state_pressed="true" android:drawable="@drawable/back_arrow_hover" />
</selector>

Using this idea, we must have at least two images. If I have ten buttons in the project, then I should have twenty images in the resource. To provide multiple density / screen size support for the application, I need 60 (20X3) images.

I have two thoughts, but I don’t know how to implement them. It:

  • we must define a method instead of a selector file.
  • we need to have one image, and we need to change the alpha value, like the iPhone.

Are there any other great Ideas. Because it increases the size of the application.

Please express your thoughts and ideas.

+3
1

, . , 9-patch png, drawables . 9-patch pngs .

, bckgrounds , .

+1

All Articles