Android开发更换字体边距变大

使用说明

  1. 在assets创建fonts文件夹,并把字体放在里面
    在这里插入图片描述
  2. 在Activity中更换字体
tv_time=(TextView)findViewById(R.id.tv_time);
tv_time.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/arial.ttf"));
tv_title=(TextView) findViewById(R.id.tv_title);
tv_title.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/SourceHanSansCNBold.otf"));
  1. 在布局文件中设置无边界 android:includeFontPadding=“false”
<TextView 
style="@style/normal_text"
android:text="系统"
android:layout_centerHorizontal="true"
android:id="@+id/tv_title"
android:textSize="25sp"
android:includeFontPadding="false"
/>
发布了131 篇原创文章 · 获赞 81 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/wei242425445/article/details/102462231
今日推荐