2

I'm trying to draw on a canvas a text and below another text that is the mirror of this text (that looks like shadow)

I'm using it in the "onDraw" method

Is there a simple way to do it?

Thanks in advance, Lior

user733284
  • 925
  • 2
  • 11
  • 18

1 Answers1

7

sure can. You will need to scale the canvas first. Try this out:

paint.setTextSize(44);
int cx = this.getMeasuredWidth() / 2;
int cy = this.getMeasuredHeight() / 2;
paint.setColor(Color.RED);
canvas.drawText("Hello", cx, cy, paint);

canvas.save();
canvas.scale(1f, -0.5f, cx, cy);
paint.setColor(Color.GRAY);
canvas.drawText("Hello", cx, cy, paint);
super.onDraw(canvas);
canvas.restore();

Try different values for the scale Y value to get effect you want.

enter image description here

eyespyus
  • 1,576
  • 19
  • 20