Working of TypedValue in Android -
when want change width of edittext in android, use line of code:
int px=(int)typedvalue.applydimension(typedvalue.complex_unit_dip,200,r.getdisplaymetrics());
can explain how works , typedvalue.complex_unit_dip return?
complex_unit_dip specifies measurement unit number refer to. wrote translates "200 dip". believe know dip is. if complex_unit_sp 200 translated "200 sp"
here source code of applydimension:
public static float applydimension(int unit, float value, displaymetrics metrics) { switch (unit) { case complex_unit_px: return value; case complex_unit_dip: return value * metrics.density; case complex_unit_sp: return value * metrics.scaleddensity; case complex_unit_pt: return value * metrics.xdpi * (1.0f/72); case complex_unit_in: return value * metrics.xdpi; case complex_unit_mm: return value * metrics.xdpi * (1.0f/25.4f); } return 0; }
Comments
Post a Comment