TextView 设置字体粗细

2019-03-08  本文已影响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>
上一篇 下一篇

猜你喜欢

热点阅读