0

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

keith
  • 3,105
  • 2
  • 29
  • 34
  • 2
    I'm reading the docs as saying that the bounds simply limit the drawn text; they don't really determine the size, apart from shrinking it to fit a minimal number of characters, apparently. You'd still need to set an appropriate text size on the `TextPaint` object, I believe. – Mike M. Jun 03 '17 at 17:39
  • Yup, I'm a wally. I made a bad assumption that this would work like the new TextView on Android that resizes the text to fill the widget size. This works the other way around :P – keith Jun 12 '17 at 17:38

1 Answers1

1

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.

TofferJ
  • 4,678
  • 1
  • 37
  • 49