dimsuz
dimsuz

Reputation: 9207

How to get default fonts properties on Android?

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? :)

Upvotes: 3

Views: 2521

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007399

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

Upvotes: 4

Related Questions