I am trying to find a simple solution to adding an outline to text, to make it stand out no matter what background sits behind it.
A google search of this issue revealed very little. I was able to find one singular thread about this here: black line around the text
But the accepted solution is only part complete. I am not sure how to actually implement what Simon has suggested. I created the Java class he describes, but I have no idea how to actually use it.
Can anyone make sense of this, or have another way of achieving this?
This question has been marked as duplicate, but the answer linked does not work. Therefore, this is still an ongoing issue. The answer linked is the following:
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
Paint strokePaint = new Paint();
strokePaint.setARGB(255, 0, 0, 0);
strokePaint.setTextAlign(Paint.Align.CENTER);
strokePaint.setTextSize(16);
strokePaint.setTypeface(Typeface.DEFAULT_BOLD);
strokePaint.setStyle(Paint.Style.STROKE);
strokePaint.setStrokeWidth(2);
Paint textPaint = new Paint();
textPaint.setARGB(255, 255, 255, 255);
textPaint.setTextAlign(Paint.Align.CENTER);
textPaint.setTextSize(16);
textPaint.setTypeface(Typeface.DEFAULT_BOLD);
Path path = new Path();
String text = "Some Text";
textPaint.getTextPath(text, 0, text.length(), 0, 100, path);
canvas.drawPath(path, strokePaint);
canvas.drawPath(path, textPaint);
super.draw(canvas, mapView, shadow);
}
The line:
super.draw(canvas, mapView, shadow);
Is picked up by the compiler as an error. The .draw part is red, as it "cannot resolve method". Since this solution is not a working solution, this question is therefore not a duplicate.
Any further ideas on how to get this to work, anyone?