My font size is 12dp.
I'm setting the font using TextPaint
, since I'm using a span. The problem is the parameter that TextPaint
accepts is in float. I'm wondering how can I convert 12 dp to float?
My font size is 12dp.
I'm setting the font using TextPaint
, since I'm using a span. The problem is the parameter that TextPaint
accepts is in float. I'm wondering how can I convert 12 dp to float?
From
android.content.res.Resources.getDimension(int id):
You can try following:
// Convert the sp to pixels
I have already have text_size defined in
res/values/dimens.xml
:Try this: