ads

mercredi 26 août 2015

LinearGradient not going transparent as end color



I've set my LinearGradient like this

Code:


TextPaint paintText = new TextPaint(Paint.ANTI_ALIAS_FLAG);
            paintText.setColor(Color.WHITE);
            paintText.setTextSize(size);
            paintText.setStyle(Paint.Style.FILL_AND_STROKE);
            paintText.setShadowLayer(3f, 3f, 3f, Color.BLACK);

            int pL = bitmap.getWidth() / 100;
            int pT = bitmap.getHeight() / 100;

            StaticLayout mTextLayout = new StaticLayout(
                    gagTitle,
                    paintText,
                    newCanvas.getWidth(),
                    Layout.Alignment.ALIGN_NORMAL,
                    1.0f,
                    0.0f,
                    false);

            int dummyHeight = mTextLayout.getHeight();
            Shader shader = new LinearGradient(0, 0, 0, (dummyHeight * 2), Color.BLACK, Color.TRANSPARENT, Shader.TileMode.MIRROR);
            Paint paint = new Paint();
            paint.setShader(shader);
            newCanvas.drawRect(new RectF(0, 0, bitmap.getWidth(), dummyHeight), paint);


I don't know why but at the end of generated gradient it's less brighter black other than being transparent.

Here is the result

example

Best Regards



Aucun commentaire:

Enregistrer un commentaire