Created
November 1, 2011 08:45
-
-
Save Skamp/1330169 to your computer and use it in GitHub Desktop.
Android: TextView set Alpha
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.util.AttributeSet; | |
import android.widget.TextView; | |
public class AlphaTextView extends TextView { | |
public AlphaTextView(Context context) { | |
super(context); | |
} | |
public AlphaTextView(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
public AlphaTextView(Context context, AttributeSet attrs, int defStyle) { | |
super(context, attrs, defStyle); | |
} | |
@Override | |
public boolean onSetAlpha(int alpha) { | |
setTextColor(getTextColors().withAlpha(alpha)); | |
setHintTextColor(getHintTextColors().withAlpha(alpha)); | |
setLinkTextColor(getLinkTextColors().withAlpha(alpha)); | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment