Naveen Chauhan
Naveen Chauhan

Reputation: 2026

Android - How to create image button of different states, default , pressed and focussed

In my android application i want to create three different image of a single image for each state pressed , default and focussed. Is there any tool that can help me to create these images.

I think you misunderstood my problem, i knows that how to use three different image for three different states. I only wants to know that how two create those three images.

here http://code.google.com/p/iosched/source/browse/android/#android%2Fres%2Fdrawable-hdpi you can see that there are three different images for three differenct states

  1. home_btn_announcements_default.png
  2. home_btn_announcements_pressed.png
  3. home_btn_announcements_selected.png

I wants to know that is there any tool that can create the above three images. I think now my question is clear to everyone.

My Question was that how to add white border for default image , gray border for focussed image. I know that how to change image according to different states. I want to ask you that is there any tool that can put white or gray border around my image.

Upvotes: 1

Views: 1106

Answers (1)

user1468129
user1468129

Reputation:

Use selector save this file in drawable/click.xml

     <?xml version="1.0" encoding="utf-8"?>
       <selector xmlns:android="http://schemas.android.com/apk/res/android" >
     <item android:state_pressed="false" android:drawable="@drawable/notPressedImage ></item>
     <item android:state_pressed="true" android:drawable="@drawable/PressedImage" ></item>

     </selector>

use click.xml (click) as button src...

Upvotes: 1

Related Questions