Is there a way to make an android button’s background translucent within xml code,
So the button has no background drawable?
Asked
Active
Viewed 3,893 times
1

java-love
- 516
- 1
- 8
- 23
-
1set it to null in xml – Pulkit Sethi Jan 22 '14 at 21:58
-
This has been asked previously, see this answer for example http://stackoverflow.com/a/11279046/2333395 – Or Bar Jan 22 '14 at 22:03
-
@Pulkit Sethi: i'm getting an error on that – java-love Jan 26 '14 at 02:31
-
1please for the love of god look up the word translucent. – baash05 Jan 06 '15 at 10:50
-
I think you mean transparent. Translucent is different. – Nom1fan Mar 22 '16 at 21:25
3 Answers
6
android:background="@android:color/transparent"
You can also set your own colors:
android:background="#80000000"
The first two hex characters represent opacity. So #00000000 would be fully transparent. #80000000 would be 50% transparent. #FF000000 is opaque.
The other six values are the color itself. #80FF8080 is a color I just made up and is a translucent sort of pinkish.

Adam
- 959
- 10
- 23
0
Set the background to the standard android transparent color.
In Code:
myButton.setBackground(getResources().getColor(android.R.color.transparent));
In xml:
android:background="@android:color/transparent"

Sound Conception
- 5,263
- 5
- 30
- 47