If I assign an integer value to change a certain text size of a TextView using java code, the value is interpreted as pixel (px), now does anyone know how to assign in sp?
thanks.
-mario_blizz
From stackoverflow
-
You can use a
DisplayMetrics
object to help convert between pixels and scaled pixels with thescaledDensity
attribute.DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); pixelSize = (int)scaledPixelSize * dm.scaledDensity;
0 comments:
Post a Comment