为什么要使用SP在Android的字体大小? [英] Why should we use sp for font sizes in Android?

查看:400
本文介绍了为什么要使用SP在Android的字体大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/2025282/difference-of-px-dp-dip-and-sp-in-android">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.

这篇关于为什么要使用SP在Android的字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆