Search code examples
androidwear-ostextrenderer

Android Wear TextRenderer does not fill the bounds


I'm trying out the fairly new TextRenderer in the Android wear support library whilst making a watch face app.

In the onDraw method, I call setText, and then I call draw and pass in the bounds from the parent onDraw method (280x280).

    String text = String.format(Locale.getDefault(), "%02d:%02d", hour, minute);
    textRenderer.setText(text);
    textRenderer.draw(canvas, bounds);

Unfortunately the text being printed out is tiny, it's super hard to find examples out there. enter image description here

I've read through the reference page and the solution is not coming to me.

https://developer.android.com/reference/android/support/wearable/complications/rendering/TextRenderer.html


Solution

  • You can set a TextPaint on the TextRenderer and it will use the text size of that TextPaint object as the initial size of your text.