在画布上绘制镜像文本

use*_*284 2 android

我试图在画布上绘制一个文本,并在另一个文本下方绘制,这是该文本的镜像(看起来像阴影)

我在"onDraw"方法中使用它

有一个简单的方法吗?

提前谢谢,Lior

eye*_*yus 6

当然可以.您需要先缩放画布.试试这个:

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();
Run Code Online (Sandbox Code Playgroud)

尝试使用不同的刻度Y值来获得所需的效果.

在此输入图像描述