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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -