views:

217

answers:

1

Hi there!

I need to draw some text on my Canvas, and I'd really avoid hardcoding some particular text size.

Is there some standard way to find a default text size (and other properties) used in the OS?

So far I found only TextView.setTextAttributes(context, resId) to which I can pass R.android.attr.textAppearance.

But the thing is that I don't want to create a TextView - I just have a Canvas and i want to draw text in it using default font.

Is it possible? :)

A: 

Try using the Paint.FontMetrics class, and methods like measureText() on Paint.

CommonsWare
You mean I should use default constructed Paint object and then getFontMetrics() will contain right values? I should try it.
dpimka
Yep, this worked. thanks.
dpimka