[英]Convert sp automatically to each other in ldpi, mdpi, hdpi, xhdpi, xxhdpi
I set textSize
in my TextView
at 14sp
in mdpi mode and I dont know what is the best size preference(sp) for textSize
in ldpi, hdpi, xhdpi, and xxhdpi modes. 我设置textSize
在我TextView
在14sp
在MDPI模式,我不知道什么是最好的尺寸偏好(SP)为textSize
在LDPI,华电国际,xhdpi和xxhdpi模式。
Is there any way to convert sp automatically to each other in ldpi, mdpi, hdpi, xhdpi, xxhdpi modes? 有什么方法可以在ldpi,mdpi,hdpi,xhdpi,xxhdpi模式下将sp自动相互转换?
You don't need to. 不用了 Sp is automatically scaled to different densities. Sp会自动缩放到不同的密度。 Its like dp in that way. 就像dp那样。 The difference is that its also scaled by a factor in the settings the user can adjust, in order to make the text easier to read for people with sight issues. 区别在于,它还会根据用户可以调整的设置按比例缩放,以使视力障碍者更容易阅读文本。
sp
is a density-independent measurement, like dp
, so there's no need to have a separate size for the other modes. sp
是与密度无关的测量值,例如dp
,因此其他模式不需要单独的大小。 The difference between dp
and sp
is just that sp
includes a scale factor based on the user's font size preference. dp
和sp
之间的区别只是sp
包含一个基于用户字体大小首选项的比例因子。
您可以使用此功能处理所有dp和sp: 实现'com.intuit.sdp:sdp-android:1.0.5'并在xml中使用,如下所示:-android:padding =“ @ dimen / _10sdp”像R.dimen._100sdp这样的java / kotlin文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.