1

Is there a way to make an android button’s background translucent within xml code,
So the button has no background drawable?

java-love
  • 516
  • 1
  • 8
  • 23

3 Answers3

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
0

The best way is to create a selector.

android_dev_
  • 412
  • 2
  • 6