android - LinearGradient and transperent colors in TextView -
i used lineat gradient set gradient color in textview , found interesting situation: set textview gredient used next code:
int c1 = getresources().getcolor(r.color.test1); int c2 = getresources().getcolor(r.color.test2); shader shader = new lineargradient(0, 0, 0, status.gettextsize(), new int[]{c1, c2}, new float[]{0, 1}, shader.tilemode.clamp); status.getpaint().setshader(shader);
i play litle bit color
- set c1=green , c2-transperent
<color name="test1">#ff00ff00</color> <color name="test2">#000000ff</color>
- set c2=blue , c1-transperent
<color name="test1">#0000ff00</color> <color name="test2">#ff0000ff</color>
so don't see transperent in second case.
can explaine nature of gradient builder?
update: @romain guy answer. play more dradient , want:
shader shader = new lineargradient(0, 0, 0, status.gettextsize(), new int[]{c1, c2, colour, colour}, new float[]{0.2f, 0.7f, 0.699f, 1}, shader.tilemode.clamp);
and status.setincludefontpadding();
true:
false:
and can see center border of solid calor , gradient collor shifting according padding value.
can calculate float values of gradients borders exectly center of characters in textview? think depend on fonttype.
the translucency effect there. problem start gradient @ 0, above text. should take account padding of textview and/or fontmetrics of font you're using.
Comments
Post a Comment