I need to set transparent background for my button, but only background, not all button. I've tried:
android:background=""
android:background="null"
and background changed on transparent, but i've got an error:
Error: String types not allowed (at 'background' with value '').
Make the button's background color transparent by changing the opacity of the button's Background color setting, using the color picker slider. See the this article about the color picker. Then you can create a button border in the Border section.
The <button> tag is used to specify the button element in HTML, which gets executed on pressed. btn – On mentioning the btn property, specifies that its a bootstrap button. bg – Specifies the background color of the button. transparent – Makes the button transparent.
Now it's time to make transparent background of android button. If you want to make 20 % transparent just add 80 at the first of your hex color code like android:background="#80000000" , if you want to make only 80 % transparent button then add 20 at the first of your hex color code like above.
To achieve this, use a color value which has an alpha channel—such as rgba. As with opacity , a value of 1 for the alpha channel value makes the color fully opaque. Therefore background-color: rgba(0,0,0,. 5); will set the background color to 50% opacity.
Material Ripple effect with transparent background some Info
android:background="?android:attr/selectableItemBackground"
For example
<Button android:layout_marginTop="15dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="?android:attr/selectableItemBackground" android:text="@string/add" android:layout_marginBottom="10dp" android:textSize="18sp" android:textStyle="bold" android:textColor="@color/fab_dark" android:id="@+id/btnOkFood" android:layout_gravity="right" />
With appcompat v7 this is supported for API => 11. It's a little better than a transparent background only because give a feedback of touch.
Type of this attribute value should be color, so use buildin attribute for transparent background with color value:
android:background="@android:color/transparent"
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