Android字體加粗的幾種樣式

起因:

因爲產品對字體加粗效果不滿意,覺得沒有別人家的粗,所以呢,作者在網上查找了些資料(ps:就幾句代碼),整理了一下,放出來,給需要的同道中人使用:

效果,老規矩,先上圖:

在這裏插入圖片描述
由圖可知,就三種加粗效果(第一行是默認的大小),然後慢慢變粗的,字體大小都一樣哦。

下面貼代碼啦:

java

代碼

		//第二行效果
 		tv1.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));

		//第三行效果
        tv2.getPaint().setFakeBoldText(true);

		//第四行效果
        tv3.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
        tv3.getPaint().setFakeBoldText(true);

xml代碼也安排上吧:

 <TextView
        android:id="@+id/tv_0"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="秋之殤"
        android:textSize="20sp" />

    <TextView
        android:id="@+id/tv_1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:text="秋之殤"
        android:textSize="20sp" />

    <TextView
        android:id="@+id/tv_2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:text="秋之殤"
        android:textSize="20sp" />

    <TextView
        android:id="@+id/tv_3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:text="秋之殤"
        android:textSize="20sp" />

好了一目瞭然,有用的小夥伴麻煩點個贊哈!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章