Pedro
Pedro

Reputation: 481

background color in a ImageButton

I put a background color in a ImageButton? How?

Upvotes: 8

Views: 23364

Answers (3)

Kidanu
Kidanu

Reputation: 63

you can use android:backgroundTint insted of android:backgroundenter image description here

<ImageButton
   android:id="@+id/imgImageTab"
   android:layout_width="@dimen/_30sdp"
   android:layout_height="@dimen/_30sdp"
   android:src="@drawable/ic_menu_home"
   android:backgroundTint="@color/blue" />

Upvotes: 0

Keith Randell Gapusan
Keith Randell Gapusan

Reputation: 83

You can use android:background=" " to set the color of ImageButton and some android widgets. ('#rrggbb' or '@android.color/blue', '@android:color/transparent'). you can follow this example as your reference.

<ImageButton
        android:id="@+id/btnGreen"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:src="@drawable/my_image.png"/>

Upvotes: 6

tomash
tomash

Reputation: 12962

android:background="#rrggbb" 

in XML file with layout definition, then use PNG file with transparency as image source

Upvotes: 7

Related Questions