[Android] The font uses the dp unit to avoid the effect of setting the system font size on the layout.
Take mx3 as an example. You can select the font size from Settings> display> font size, for example:
Figure 1. mx3
This may cause the "associated" display of the software to be incomplete on a fixed page. For example.
Figure 2. Incomplete font display
To solve this problem, change the unit of font size in TextView from sp to dp.
This example shows that the height of the content cannot be fully displayed due to the font size setting. Another case is that because the font size increases, only one line of content can be displayed, and the current behavior is two lines. This may also damage the original design aesthetic. Therefore, for a page with strict typographical requirements, use the dp unit for its font size.
Appendix:
Figure 1 sets "default", "medium", and "large", which affects fontScale under Configuration.
Run the following code to obtain the result:
Configurationconf = getResources (). getConfiguration (); LogOut. e ("fontScale =" + conf. fontScale );
Print result:
Lab. sodino. network. mainActivity-> fontScale = 1.12 // large lab. sodino. network. mainActivity-> fontScale = 1.06 // medium lab. sodino. network. mainActivity-> fontScale = 1.0 // default