Background color in ImageButton

Am I putting a background color in an ImageButton? How?

+4
source share
2 answers
android:background="#rrggbb" 

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

+5
source

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 a 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"/> 
+3
source

Source: https://habr.com/ru/post/1313865/


All Articles