在Canvas机器人喷漆边框的文本喷漆、边框、机器人、文本

2023-09-06 00:45:03 作者:彪悍的人生不需要解释

我想在画布类似油漆:

我该怎么办了边框的效果?谢谢

How can I do the bordered effect? Thanks

推荐答案

绘制文本两次。先用像这样一个补漆绘制文本:

Draw the text two times. First draw the text with a fill paint like so:

Paint fillPaint = new Paint();
fillPaint.setColor(Color.MAGENTA);
canvas.drawText(.... fillPaint);

然后用像这样一搏再次绘制它:

Then draw it again with a stroke like so:

Paint stkPaint = new Paint();
stkPaint.setStyle(Style.STROKE);
stkPaint.setStrokeWidth(8);
stkPaint.setColor(Color.WHITE);
canvas.drawText(.... stkPaint);