2

I have a two png files. The button and it's "pressed state".

1)How do I replace the default android button with my png(the text of the button is included in the png, there's no need to define a textView over the image.

2) And also how do I implement the "onPress" state png???.

I've been 3 days searching for answers but there's little to no information on this subject in particular. I just found the rotate animations an all of that, but nothing on how to replace a default button with a drawable and then use another png file when the user press the button

JAF
  • 350
  • 3
  • 19
  • 1) `android:background` 2) `android:background` using a `StateListDrawable` – CommonsWare Sep 06 '15 at 22:05
  • `I've been 3 days searching for answers but there's little to no information on this subject in particular.` : have you find `selector` drawable ? you can do same by creating selector with normal and pressed state. see following example [Android Button Selector tutorial with example](http://www.compiletimeerror.com/2014/03/android-button-selector-tutorial-with.html) – ρяσѕρєя K Sep 06 '15 at 22:06
  • 3
    Where did you search? on The Mickey Mouse Adventures? I found the duplicate post in no time... – Phantômaxx Sep 06 '15 at 22:08
  • sorry Frank. You found it quickly cause you knew what to look. I'm a noob at this, sometimes is harder to know what you're looking for – JAF Sep 06 '15 at 22:52
  • 1
    Thanks to all for your answers, I could implement the selector correctly xD – JAF Sep 06 '15 at 23:04

1 Answers1

2

If you want to use an image in your Button you just have to put it on the drawable folder and then in the background of your Button you can do:

android:background="@drawable/image"
Francisco Romero
  • 12,787
  • 22
  • 92
  • 167