[英]what is the difference between scaledDensity and density in Android`s DisplayMetrics class?
TextView compute text size value with scaledDensity instead of density. TextView使用scaledDensity代替密度来计算文本大小值。 so what`s the difference between these two values? 那么这两个值有什么区别?
A scaling factor for fonts displayed on the display. 显示屏上显示的字体的比例因子。 This is the same as density, except that it may be adjusted in smaller increments at runtime based on a user preference for the font size. 这与密度相同,除了可以在运行时根据用户对字体大小的偏好以较小的增量进行调整。
The logical density of the display. 显示的逻辑密度。 This is a scaling factor for the Density Independent Pixel unit, where one DIP is one pixel on an approximately 160 dpi screen. 这是密度独立像素单位的比例因子,其中一个DIP是大约160 dpi屏幕上的一个像素。
sp SP
Scale-independent Pixels – this is like the dp unit, but it is also scaled by the user's font size preference. 与缩放无关的像素–就像dp单位一样,但是它也通过用户的字体大小首选项进行缩放。 It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference. 建议您在指定字体大小时使用本机,以便针对屏幕密度和用户喜好进行调整。
dp DP
A virtual pixel unit that you should use when defining UI layout, to express layout dimensions or position in a density-independent way. 在定义UI布局时应使用的虚拟像素单位,以密度独立的方式表示布局尺寸或位置。
The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, which is the baseline density assumed by the system for a “medium” density screen. 与密度无关的像素等效于160 dpi屏幕上的一个物理像素,这是系统为“中”密度屏幕假定的基线密度。
you can find nice explanation here Difference of px, dp, dip and sp in Android and Android units 您可以在此处找到很好的解释Android和Android单位 中px,dp,dip和sp的差异
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.