How to remove a standard ImageButton background image?

In ImageButton I want to remove the standard background image of a button. Http://developer.android.com says that you need to define its own background image or set the background color to transparent. I tried to set the black background, but it didn’t affect ...

+64
android imagebutton
Mar 28 2018-11-11T00:
source share
9 answers

You can use android:background="@null" for ImageButton .

+174
Mar 28 2018-11-11T00: 00Z
source share

ImageButton.setBackgroundResource(0)

+22
Mar 28 '11 at 9:55
source share

The best choice is not a transparent background for your ImageButton .

Give your user feedback at the touch of a button.

 android:background="?attr/selectableItemBackgroundBorderless" 
+10
Nov 02 '16 at 23:46
source share

No, it should be transparent, not black. Try the color: # 00FFFFFF

+4
Mar 28 '11 at 9:40
source share

use the following property in your xml ImageButton:

 android:background="@drawable/icon" 

where the icon is the name of the image contained in your drawing.

+3
Mar 28 '11 at 9:50
source share

Do not use button.setBackgroundResource(0) ; on some devices you will receive:

android.content.res.Resources $ NotFoundException: Resource ID # 0x0

Better use button.setBackgroundColor(Color.TRANSPARENT);

+1
Jun 16 '15 at 7:47
source share
 YourImageButton.setBackgroundColor(Color.TRANSPARENT); 
0
Dec 10 '12 at 20:12
source share
 myButton.setBackgroundResource(0); 
0
Feb 25 '13 at 18:02
source share

Using:

 android:background="@null" 

in your xml layout.

0
Dec 12 '17 at
source share



All Articles