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
Based on the the source code of setTextSize:
public void setTextSize(int unit, float size) {
Context c = getContext();
Resources r;
if (c == null)
r = Resources.getSystem();
else
r = c.getResources();
setRawTextSize(TypedValue.applyDimension(
unit, size, r.getDisplayMetrics()));
}
I build this function for calulating any demension to pixels:
int getPixels(int unit, float size) {
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
return (int)TypedValue.applyDimension(unit, size, metrics);
}
Where unit is something like TypedValue.COMPLEX_UNIT_SP.