Could someone please help me as I can no longer get drawTextOnPath to work?
The watch face I wrote doesn't work properly after upgrades to watch software (and phone) so I'm writing it again from scratch using the current watch face template (targetSdk 27). At the moment I have this (in a method following the set up of the background bitmap during the onCreate of the Engine class):
Paint mDayDialPaint2 = new Paint();
mDayDialPaint2.setColor(Color.RED);
mDayDialPaint2.setTextSize(10f);
mDayDialPaint2.setAntiAlias(true);
mDayDialPaint2.setStrokeWidth(65f);
mDayDialPaint2.setStyle(Paint.Style.FILL_AND_STROKE);
mDayDialPaint2.setTextAlign(Paint.Align.LEFT);
// canvas.drawTextOnPath(wkendText, textPathDay, 1f, 4f, mDayDialPaint2);
canvas.drawTextOnPath("abcdefgh", textPathDay, 1f, 4f, mDayDialPaint2);
//View.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
//canvas.drawPath(textPathDay, mDayDialPaint2);
When I uncomment canvas.drawPath as a test, it works. So the path exists and is in the right place.
I've tried a variety of text sizes and stroke widths, several variations of style, with and without the text align.
Following suggestions from SO and other places I've also tried:
I did find a SO post Canvas.drawTextOnPath(...) not working on Lollipop that says drawTextOnPath is broken as of Lollipop and you have to rescale and recalculate everything on the canvas but it's a lot of work and I've seen several posts since then that seem to find it works ok so I suspect it's not necessary.
Any other suggestions?
I managed to fix this by calling that code later. Originally it was in the Engine.onCreate, following the initialization of the background and the watch face; now it is called at the end of the onApplyWindowinsets and works correctly.