美文网首页
Calligraphy全局加载Noto字体时去除TextView

Calligraphy全局加载Noto字体时去除TextView

作者: Trojx | 来源:发表于2016-08-16 21:30 被阅读129次

    使用Calligraphy能够非常方便地将应用的全局字体改为自定义的字体。
    它的使用方法非常简单,详见该项目Github (https://github.com/chrisjenx/Calligraphy
    在使用Calligraphy全局加载常用的NotoSansCJKsc字体时会出现每一个TextView的上下空白区域过大,不利于界面的布局。

    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字体后出现上下空白

    一开始以为是TextView的padding被设置成了不为零的值,结果发现手动设置padding=0并没有用。

    解决办法:

    android:includeFontPadding="false"
    这个属性用来设置文本是否包含顶部和底部额外空白,默认是true

    调整后效果

    相关文章

      网友评论

          本文标题:Calligraphy全局加载Noto字体时去除TextView

          本文链接:https://www.haomeiwen.com/subject/pinpsttx.html