button - How to Set Opacity (Alpha) for View in Android -


I have one of the following buttons:

  & lt; Android: text = "Submit" Android: id = "@ + id / button01" Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" & gt; & Lt; / Button & gt;  

In my onCreate () event, I'm calling Button01 this way:

  setContentView (R.layout Main); See Button 101 = this.findViewById (R.id.Button01); Button01.setOnClickListener (this);  

The application has a background, and I want to set the opacity on this submit button. How can I set the opacity for this scene? Is there anything that I can set up to Java, or can I set in main.xm file?

On the Java side I tried the button 01. Mutate (). SetAlpha (100) , but he gave me an error.

I got your question when there is a problem like this with TextView and Override OnSetAlpha was able to solve it. You might try something similar to your button:

  import android.content.Context; Import android.util.AttributeSet; Import android.widget.TextView; Public Class Alphaextex TextView Extends {Public Altequetview (context context) {super (reference); } Public Altextview (context references, AttributeSet attrs) {super (references, ethers); } Public AltaVetview (Reference Reference, AttributeSet attrs, int defStyle) {super (references, attrs, defStyle); } @ Override Public Boolean on Stelfa (Intel Alpha) {getTextColors (). WithAlpha (alpha)); SetHintTextColor (getHintTextColors () withAlpha (alpha).); SetLinkTextColor (getLinkTextColors () withAlpha (alpha).); Back true; }}  

Comments