在 android 5.0 上,如果文本视图设置了 lineSpacingExtra,并且只有一行文本,则文本视图不显示行间距

On android 5.0,if a textview has set lineSpacingExtra, and has only one line text, the textview doesn't show linespacing

5.0以下与其他android版本不同! 演示代码:

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:lineSpacingExtra="100dp"
    android:text="Hello World!"/>

在 android 5.0 上,它显示:

低于android5.0,显示:

但是如果textview超过两行,它们显示的是一样的! 我怎样才能让它们在不同的 os 版本上显示相同? 求助!

你可以像

一样设置一个paddingBottom到Lollipop的视图
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:lineSpacingExtra="100dp"
    android:text="Hello World!"
    android:paddingBottom="@dimen/padding"/>

并在 dimens (values-v19) 中设置 padding=0dp 并在 dimens (values-v21)

中设置 padding=100dp