I am trying to create a transparent Button. In details I set the background's button with an image and I would like to modify the transparency of the button in order to see the background layout's color.
you can use setAlpha()
method to your Button.
Usingbutton.setAlpha(0.0)
from your java code, will make your button fully transparent.
Or you can also use it in your layout xml.
Inside your <Button />
tag use the following attribute:
android:alpha="0"
If you use
?android:attr/selectableItemBackground
you'll have a transparent background with Ripple Effect according to this article of android-developers
Here an example
<Button
android:id="@+id/test"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Change Password"
android:background="?android:attr/selectableItemBackground"
android:textSize="12sp"
android:gravity="left|center"/>
You can use android:alpha="0.5"
to set your button half-transparent (the value has to be a float, where 0.0 is invisible and 1.0 is opaque), but be aware that this only works from API Level 11 (Android 3.0) onwards.
Another option would be to make change the background image itself and make it transparent using a graphics program like Gimp or Fireworks.
simply if you want to make button transparent you can use
android:background="@android:color/transparent"
or use #0000
four zero in has code.let it only be 4 otherwise it will be considered as black.
hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With