I put a background color in a ImageButton? How?
Asked
Active
Viewed 2.2k times
3 Answers
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
-
2a transparent background can be done like this... android:background="#00000000" – Someone Somewhere May 13 '11 at 22:23
-
1@SomeoneSomewhere `android:background="@null"` – Vlad Apr 20 '20 at 13:06
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"/>

Keith Randell Gapusan
- 83
- 2
- 8
0
you can use android:backgroundTint insted of android:background
<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