使用Calligraphy能夠非常方便地將應用的全局字體改為自定義的字體。
它的使用方法非常簡單,詳見該項目Github (https://github.com/chrisjenx/Calligraphy)
在使用Calligraphy全局加載常用的NotoSansCJKsc字體時會出現(xiàn)每一個TextView的上下空白區(qū)域過大,不利于界面的布局。

NotoSansCJKsc-DemiLight
<TextView
android:id="@+id/tv_debug_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="文字文字TEXTtext文字文字TEXTtext文字文字TEXTtext" />
<TextView
android:id="@+id/tv_debug_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="文字文字TEXTtext文字文字TEXTtext文字文字TEXTtext文字文字TEXTtext文字文字TEXTtext文字文字TEXTtext" />

使用Calligraphy全局加載Noto字體后出現(xiàn)上下空白
一開始以為是TextView的padding被設置成了不為零的值,結果發(fā)現(xiàn)手動設置padding=0并沒有用。
解決辦法:
android:includeFontPadding="false"
這個屬性用來設置文本是否包含頂部和底部額外空白,默認是true

調(diào)整后效果