Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageButton in Android with transparent background [duplicate]

I have follow this post to make ImageButton in android

android image button

The image appears to the button but it has some background , my Image is a png image and I want the button to be transparent background

any one help please

like image 819
Amira Elsayed Ismail Avatar asked Feb 08 '12 15:02

Amira Elsayed Ismail


People also ask

How do I make a background transparent in ImageButton?

You can specify a transparent background for the image button. The result will be a clickable image that acts like a button but can look like whatever you want it to look like. Just set android:background="@null" for the image button.

How to use ImageButton in android studio?

Save the XML file in your project res/drawable/ folder and then reference it as a drawable for the source of your ImageButton (in the android:src attribute). Android will automatically change the image based on the state of the button and the corresponding images defined in the XML.

What is ImageButton in android?

An ImageButton is an AbsoluteLayout which enables you to specify the exact location of its children. This shows a button with an image (instead of text) that can be pressed or clicked by the user.


2 Answers

add this line to your ImageButton xml layout.

android:background="@null"
like image 101
Sunny Avatar answered Oct 16 '22 14:10

Sunny


Here's an alternative solution that worked for me:

android:background="@android:color/transparent"

As Sunny said, add it to the ImageButtons' XML layout

like image 11
mestrini Avatar answered Oct 16 '22 16:10

mestrini