Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - paint.setShadowLayer Ignoring shadowColor

I am facing issue with shadow color, setShadowLayer method is ignoring shadowColor (Here i specified Color.RED in my code) instead of setShadowLayer is taking paint color (Here Color.argb(255, 50, 153, 187)). Below is my paint settings and find attached image for reference, thanksenter image description here

    paint.setAntiAlias(true);
    paint.setColor(Color.argb(255, 50, 153, 187));
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeJoin(Paint.Join.ROUND);
    paint.setStrokeWidth(STROKE_WIDTH);
    paint.setStrokeCap(Paint.Cap.ROUND);
    paint.setShadowLayer(7.0f, 20.0f, 2.0f, Color.RED);
like image 610
Dhiral Pandya Avatar asked Jan 13 '15 15:01

Dhiral Pandya


1 Answers

the shadowLayer works only it the hardware acceleration is disabled. Add

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { 
      setLayerType(LAYER_TYPE_SOFTWARE, paint); 
}

and it should work

like image 93
Blackbelt Avatar answered Oct 10 '22 05:10

Blackbelt