为什么要使用SP在Android的字体大小?字体大小、要使、SP、Android

由网友(染指醉紅尘)分享简介:可能重复: Difference的像素,DP,畅游和SP在Android的 我是新来的Andr​​oid和我尝试​​本教程 I am new to Android and I was trying out this tutorial在该教程中,他们用单位SP的TEXTSIZE属性,DP的其他属性。In tha...

可能重复:   Difference的像素,DP,畅游和SP在Android的

我是新来的Andr​​oid和我尝试​​本教程

I am new to Android and I was trying out this tutorial

在该教程中,他们用单位SP的TEXTSIZE属性,DP的其他属性。

In that tutorial, they used the unit "sp" for textSize attribute and "dp" for other attributes.

请告诉我如何SP不同于DP?

Please tell me how sp differs from dp?

推荐答案

DP 有一定的比例过渡到 PX DP = PX *比值。其中,永远不会改变任何特定的设备上。

The dp has constant ratio transition to px: dp = px * ratio. Where ratio will never change on any particular device.

SP (S为缩放)具有可扩展性比: SP = PX *比例*比例。其中,永远不会改变,但比例是用户可配置的。这比例可以使用的人谁需要更大的字体大小,例如,能够更舒适地使用设备。

While sp (s for scaled) has scalable ratio: sp = px * ratio * scale. Where ratio never changes, but scale is user configurable. This scale can be used by people who need larger font sizes, for example, to use device more comfortably.

阅读全文

相关推荐

最新文章