Android is a headache adaptation problem.
---------
The units in Android probably have these:
Dip, SP, often used. Sometimes the PX is used.
---------
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
SP and dip are the same. Only the SP will vary depending on the device and is also affected by user settings (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 so), 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 great extent. SP to use? My advice is not to.
It depends on you. Suppose your app is intended for people who have bad eyes (for example, hard-working elders), and you can specify a super-large font directly. If you do not consider vision, for the sake of beauty, do not let the user change the font size. Assume that the two types of people are covered. Just use SP (not necessarily ~).
About units in Android (DP, SP)