答案在于从整体上看待这个特定问题。
使用“sp”字体大小的动机在于让开发人员能够在面对用户更改其设备上的字体大小时控制其布局。
例子:
让我们看两个极端情况:
1)用户选择字体大小“小”
这是我的布局的样子:
http://postimg.org/image/kiyqeo2bh/
这是布局xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
tools:context=".MainActivity"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_row="0"
android:layout_column="0"
android:text="Material-Design ist die Scheiße"
android:textSize="18sp"
android:background="#ffff0000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_row="0"
android:layout_column="0"
android:text="Material-Design ist die Scheiße"
android:textSize="25sp"
android:background="#ffff0000" />
2)如果用户选择字体大小“巨大”:
这就是我的布局:
http://postimg.org/image/d7rax9wob/
在案例 1) 中,我的布局 xml 与上面相同。
因此,正如您所看到的,顶部的 TextView 在 sp 中具有某种完美的字体大小,因为它不会对整个字体大小范围(从小到大)进行换行。但是在案例 2) 中,底部的 TextView 完全搞砸了你的布局/设计。
因此,作为开发人员,您可以迭代并决定 sp 中的大小适合您的设计,而 android 将为您绘制它。