Addev
Addev

Reputation: 32221

Paint bordered text in a Canvas android

I'd like to paint in a Canvas something like:

enter image description here

How can I do the bordered effect? Thanks

Upvotes: 33

Views: 16468

Answers (1)

Samuel
Samuel

Reputation: 17161

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);

Upvotes: 65

Related Questions