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

  1. set c1=green , c2-transperent
    <color name="test1">#ff00ff00</color> <color name="test2">#000000ff</color> 

enter image description here

  1. set c2=blue , c1-transperent
    <color name="test1">#0000ff00</color> <color name="test2">#ff0000ff</color> 

enter image description here

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: enter image description here

false: enter image description here

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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -