Hello. Im trying to customize a textview to add a gradientoverlay, a
dropshadow and a maskfilter.
There seems like i cant combine the different methods as i thought i
would.
For example when i use both gradient and shadow my shadow gets the
same color as the gradient.
Combinding dropshadow and a maskfilters renders no text at all. While
a combination of gradient overlay seems to work fine.

I have extended TextView and overriden onDraw:

    protected void onDraw(Canvas canvas) {
        TextPaint paint = getPaint();
        // paint.setShader(new LinearGradient(8f, 80f, 30f, 20f,
Color.RED,Color.WHITE,Shader.TileMode.MIRROR));
        float height = paint.getFontSpacing();
        Toast.makeText(getContext(), "h: "+height,
Toast.LENGTH_SHORT).show();

        paint.setMaskFilter(new EmbossMaskFilter(new float[] { 0,
0.3f, 0 },0.95f, 10, 0.1f));

        // paint.setShadowLayer(0.1f, 30f, 5f,
Color.parseColor("#ffffff"));

        paint.setShader(new LinearGradient(0, 0, 0, height,
                new int[]
{ GRADIENT_START,GRADIENT_MID,GRADIENT_MID,GRADIENT_END },
                new float[] {0,0.4f,0.6f,1f},
                Shader.TileMode.CLAMP));

        super.onDraw(canvas);
    }

Does these filters not work together? Is it the wrong aproach to try
to extend a textview, should i create my own View for drawing thext
with gradients, shadows and masks?

// Anders

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to