美文网首页
TextView 设置字体粗细

TextView 设置字体粗细

作者: 初心一点 | 来源:发表于2019-03-08 23:50 被阅读0次

设置字体粗细

代码:

TextView txt1 = findViewById(R.id.txt1);
TextPaint tp = txt1.getPaint();
tp.setFakeBoldText(true);

XML:

<?xml version="1.0" encoding="utf-8"?>
<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="100dp"
        android:layout_height="100dp"
        android:text="你好好吧"
        android:textStyle="bold" />
    <TextView
        android:id="@+id/txt1"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:text="Are you ok?"
        android:textStyle="normal" />
</LinearLayout>

相关文章

网友评论

      本文标题:TextView 设置字体粗细

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