Effect shadow in rectangle canvas
android, canvas, shadow
Solution
This question contained the following code :
Paint mShadow = new Paint();
// radius=10, y-offset=2, color=black
mShadow.setShadowLayer(10.0f, 0.0f, 2.0f, 0xFF000000);
// in onDraw(Canvas)
canvas.drawBitmap(bitmap, 0.0f, 0.0f, mShadow);
So customize it a bit to your needs and that will do the trick.
In your case just add `pincel1.setShadowLayer(10.0f, 0.0f, 2.0f, 0xFF000000);` to your code.
Problem
I have drawn a rectangle with canvas and I wonder if there is any property or way of giving a small shadow. ``` protected void onDraw(Canvas canvas) { super.onDraw(canvas); Paint pincel1 = new Paint(); pincel1.setColor(Color.rgb(151, 217, 69)); RectF rectangle = new RectF(30, 20,200,100); canvas.drawRoundRect (rectangle, 6, 6, pincel1); } ``` Thanks