Cole Cole - 1 month ago 11
Android Question

Any way to remove the grey background from ImageButtons?

I have an ImageButton and I'd like to remove the ugly (IMHO) background that surrounds the Image. I could just add an ImageView, but they're very hard to get set perfectly in a Layout like the grey one pictured. [gravity "Center" doesn't make it go to the middle, just centers it Vertically.)

So any way to remove that?

enter image description here

Answer

Just use android:background="#0000" (#0000 same with #00000000) or

ImageButton imageButton = new ImageButton(this);
imageButton.setBackgroundDrawable(null);