Is It Possible To Make The Background Of A Button Transparent?
I have a button like so... Sorry if it looks dark but as you can see, I have set the height and width to wrap content but the scaletype is not fitxy so there is still 'button exce
Solution 1:
You can used ImageButton. Do it in your xml
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButtonSettings"
android:src="@drawable/tabbar_icon"
android:background="@android:color/transparent"/>
or programmatically. this is the simple only you have to set background color as transparent
ImageButton btn=(ImageButton)findViewById(R.id.ImageButton01);
btn.setBackgroundColor(Color.TRANSPARENT);
Solution 2:
use an ImageButton
and set the background of it to transparent like this : android:background="@android:color/transparent"
<ImageButton
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:src="@drawable/btn_login" />
Solution 3:
//yes you can do it thru android:alpha
in xml
//add this below line in your button properties and change your alpha level as what you want
android:alpha="0.5"
Solution 4:
use #0000
(only four zeros otherwise it will be considered as black) this is the color code for transparent. You can use it directly but I recommend you to define a color in color.xml so you can enjoy re-usefullness of the code.
Solution 5:
Add the following attribute to the button tag
<button
android:background="@android:color/transparent"/>
Post a Comment for "Is It Possible To Make The Background Of A Button Transparent?"