为什么我们应该在 Android 中使用 sp 作为字体大小? [英] Why should we use sp for font sizes in Android?

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

问题描述

可能的重复:
android中px、dp、dip和sp的区别

我是 Android 新手,我正在尝试本教程

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

在那个教程中,他们对 textSize 属性使用单位sp",对其他属性使用单位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 * ratio.ratio 在任何特定设备上永远不会改变.

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

虽然sp(s代表缩放)有缩放比例:sp = px * ratio * scale.其中 ratio 永远不会改变,但 scale 是用户可配置的.此scale 可供需要更大字体大小的人使用,例如,更舒适地使用设备.

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.

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

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