I am creating a custom drawable (it extends from Drawable) and I am trying to apply a shadow effect to it.
Here is part of my code:
public void draw(Canvas canvas) { Path path = new Path(); path.moveTo(0, 0); path.lineTo(0, Y/2); path.lineTo(X/2, Y); path.lineTo(X, Y/2); path.lineTo(X, 0); path.lineTo(0, 0); Paint paint = new Paint(); paint.setColor(context.getResources().getColor(R.color.red_dark)); paint.setStyle(Style.FILL_AND_STROKE); paint.setStrokeWidth(2f); paint.setShadowLayer(1, 0, 10f, context.getResources().getColor(R.color.black)); canvas.drawPath(path, paint); }
I donβt know why, but it puts a shadow with the same color, I double-checked everything and I donβt see where the problem is. I test it on a galactic connection. But on the emulator, it works fine.
source share