I have a button with an image background and text. The background alpha should be 0.7 and the text alpha should be 1.0.
<Button
android:background="@drawable/button"
android:alpha="0.7"
android:text="Button"
/>
By this code I get 0.7 alpha for the whole button. Is there a way to change only the drawable alpha?
CSS Code: In this section, we will design the button using CSS property. We will use the background-color: transparent; property to set the button with transparent look. Complete Code: In this section, we will combine the above two sections to create a transparent background button.
setAlpha(51); Here you can set the opacity between 0 (fully transparent) to 255 (completely opaque). The 51 is exactly the 20% you want.
If you want just to change the color, use the app:backgroundTint attribute.
To get α subtract your confidence level from 1. For example, if you want to be 95 percent confident that your analysis is correct, the alpha level would be 1 – . 95 = 5 percent, assuming you had a one tailed test. For two-tailed tests, divide the alpha level by 2.
myButton.getBackground().setAlpha(200);
can try this in your code.
public abstract void setAlpha (int alpha)
Added in API level 1
Specify an alpha value for the drawable. 0 means fully transparent, and 255 means fully opaque.
Try this:
<Button
android:background="#3000"
android:text="Button"
/>
here #3000 => #argb where 'a' sets the alpha component.
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