I can set ImageButton background transparent in layout.xml
using:
android:background="@android:color/transparent"
How I can acomplish same thing using java code? Something like ib.setBackgroundColor(???);
CSS Code: In this section, we will design the button using CSS property. We will use the background-color: transparent; property to set the button with transparent look. Complete Code: In this section, we will combine the above two sections to create a transparent background button.
setImageResource(int) method. To remove the standard button background image, define your own background image or set the background color to be transparent. 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).
This is the simple only you have to set background color as transparent
ImageButton btn=(ImageButton)findViewById(R.id.ImageButton01); btn.setBackgroundColor(Color.TRANSPARENT);
Do it in your xml
<ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageButtonSettings" android:layout_gravity="right|bottom" android:src="@drawable/tabbar_settings_icon" android:background="@android:color/transparent"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With