Created
November 27, 2013 05:57
-
-
Save goodev/7671292 to your computer and use it in GitHub Desktop.
设置文字的 Alpha 值
This file contains hidden or 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
public class AlphaForegroundColorSpan extends ForegroundColorSpan { | |
private float mAlpha; | |
public AlphaForegroundColorSpan(int color) { | |
super(color); | |
} | |
[…] | |
@Override | |
public void updateDrawState(TextPaint ds) { | |
ds.setColor(getAlphaColor()); | |
} | |
public void setAlpha(float alpha) { | |
mAlpha = alpha; | |
} | |
public float getAlpha() { | |
return mAlpha; | |
} | |
private int getAlphaColor() { | |
int foregroundColor = getForegroundColor(); | |
return Color.argb((int) (mAlpha * 255), Color.red(foregroundColor), Color.green(foregroundColor), Color.blue(foregroundColor)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment