Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button with BOTH color and background image

Is there any way to set the color and background image for a button? I want a green button with a transparent .png but it seems you can only have one or the other.

like image 865
gatzkerob Avatar asked May 06 '12 22:05

gatzkerob


2 Answers

(Don't) Use an ImageView

Set your set your green button background image as the background, and your transparent png as the src. You can apply a selector to the background just the same as you would to a button also...

EDIT: Actually there is an ImageButton already made for this, you should be using that instead. Slipped my mind.

like image 183
FoamyGuy Avatar answered Oct 04 '22 05:10

FoamyGuy


Try This piece of code it works for me :)

<ImageButton
android:id="@+id/button5"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
...
android:src="@drawable/settingbtn"
android:background="@drawable/red_color"
     />
like image 28
Ali Jafar Avatar answered Oct 04 '22 06:10

Ali Jafar