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
  • 517
  • 1
  • 7
  • 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
  • 948
  • 9
  • 22
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,146
  • 4
  • 27
  • 47
0

The best way is to create a selector.

android_dev_
  • 402
  • 2
  • 6