在TextView中未正确设置Android自定义字体(nunito)

我在我的 Android TextView中使用自定义字体.

Typeface tf = Typeface.createFromAsset(getAssets(),
                "nunitomedium.ttf");
        txt2= (TextView) findViewById(R.id.txt2);
        txt2.setTypeface(tf);

但是线条之间的填充没有正确显示.

<TextView
        android:id="@+id/txt2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/_10sdp"
        android:layout_marginRight="@dimen/_10sdp"
        android:layout_marginTop="@dimen/_15sdp"
        android:text="You can send emergency blast to friends and family whenever you feel uncomfortable. Once activated, you will be able to send an emergency blast to your safety network within seconds with the pressing of one button."
        android:textColor="@color/colorBlack"
        android:textSize="@dimen/_15sdp" />

这是我的输出:

《在TextView中未正确设置Android自定义字体(nunito)》

我也试过以下代码:

android:includeFontPadding="false"

但仍然是同一个问题.不确定,但我也尝试使用Here的justifyTextView,但同样的问题.以前有人遇到过同样的问题吗?

提前致谢.

编辑:

如果我使用android:lineSpacingExtra第一行有更多的空间,然后其他行.这是我的代码和输出.

<TextView
        android:id="@+id/txt2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/_10sdp"
        android:layout_marginRight="@dimen/_10sdp"
        android:layout_marginTop="@dimen/_15sdp"
        android:lineSpacingExtra="@dimen/_5sdp" <<<<<<<
        android:text="You can send emergency blast to friends and family whenever you feel uncomfortable. Once activated, you will be able to send an emergency blast to your safety network within seconds with the pressing of one button."
        android:textColor="@color/colorBlack"
        android:textSize="@dimen/_15sdp" />

《在TextView中未正确设置Android自定义字体(nunito)》

最佳答案 迟到了 – 我们有完全相同的问题,通过用最新的谷歌字体替换.ttf字体文件完全修复 – 这个字体的早期版本很糟糕.不要忘记删除你同时放置的任何android:lineSpacingMultiplier软糖.

点赞