Android is a headache adaptation problem.
---------
The units in Android probably have these:
Commonly used dip, SP, sometimes used to PX.
---------
Two classes are introduced:
Typedvalue: There are some units that convert related methods.
Displaymetrics:
Displaymetrics dm = new Displaymetrics (); Getwindowmanager (). Getdefaultdisplay (). Getmetrics (DM);
Displaymetrics have these units to convert related fields:
---------
Their relationship:
Dip = displaymetrics.density * px
= (densitydpi/160) * px
The SP and dip are the same, except that the SP will be affected by the user settings in addition to the device's differences (the general path is in: Settings-appearance-font size). And, to be indignant, on the Sony Xperia C3 (do not know whether all Xperia is this), the system default font size display is "normal", the actual display effect and other equivalent machines in the "big" font is the same. This means that some systems have default font size settings that are inconsistent with the Android native system. So how do you control the effect of the display?
---------
Do you want to use dip, sp? Dip to use. Solve the adaptation problem to a large extent. SP to use? My advice is not to. It depends on you, if your app is dedicated to the eyes of bad (such as hard elders) people use, you can directly specify the super-large font, if you do not consider the vision, in order to beautiful, do not let the user change the font size; If you cover these two types of people, use SP bar (not necessarily ~)!