6

I put a background color in a ImageButton? How?

Pedro
  • 451
  • 2
  • 6
  • 5

3 Answers3

7
android:background="#rrggbb" 

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

tomash
  • 12,742
  • 15
  • 64
  • 81
6

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"/>
0

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" />
Kidanu
  • 63
  • 2
  • 9