I want my buttons to be transparent as I have an image on the activity as a background. If the buttons are not transparent, those buttons are covering the image and image background seems useless.
If I use android:background="@android:color/transparent"
, it is making my button completely invisible except the text on it. So, I need the button to be transparent provided it should be visible that there is a button. Code snippet would be appreciated.
<Button
android:id="@+id/new_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent" //this line makes the button completely invisible.
android:text="@string/label" />
Apply border for button
Apply selector for button, like this
Modify this for you =)
I've hard coded the colour, but you should store it in colors.xml
Modify the first two characters, A0, to adjust how much transparency you want and the last 6 characters the color you want.
Just try to use below code in java
that make all button transparent.
If you just want white borders, and the text/icons in the button, but the button background transparent create the following drawable (I named it button_border.xml):
And use it as a background for the button:
I'd guess there is a more elegant way to do it with themes, but I'm not that far yet. In the button_border drawable you can add rounded corners and whatnot...