Skip to content Skip to sidebar Skip to footer

What Is The Unit For Textpaint Settextsize In Android?

The dev. docs does not say anything about the unit. Pixels, dps, cm? http://developer.android.com/reference/android/graphics/Paint.html#setTextSize(float) From experimenting, the m

Solution 1:

It is pixels, since setText() is native method and in Paint.h native call transforms the float to scalar value, then draws it. Of course, you can apply dip for support various screens by:

 float textSize =  TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, getResources().getDimension(R.dimen.text_size), getResources().getDisplayMetrics());

Post a Comment for "What Is The Unit For Textpaint Settextsize In Android?"