TextView bold via xml file?

2019-03-08 06:25发布

Is there a way to bold the text in a TextView via XML?

<TextView
   android:textSize="12dip"
   android:textAppearance="bold"  -> ??
</TextView>

Thanks

6条回答
孤傲高冷的网名
2楼-- · 2019-03-08 07:02
Just you need to use 

//for bold
android:textStyle="bold"

//for italic
android:textStyle="italic"

//for normal
android:textStyle="normal"

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textStyle="bold"
    android:text="@string/userName"
    android:layout_gravity="left"
    android:textSize="16sp"
/>
查看更多
Luminary・发光体
3楼-- · 2019-03-08 07:03

use textstyle property as bold

android:textStyle = "bold";
查看更多
爷、活的狠高调
4楼-- · 2019-03-08 07:04

just use

android:textStyle="bold"
查看更多
We Are One
5楼-- · 2019-03-08 07:07

Use android:textStyle="bold"

like this

<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="12dip"
android:textStyle="bold"
/>

There are many ways to make Android TextView bold. Check out this link https://androidride.com/android-textview-bold/

查看更多
不美不萌又怎样
6楼-- · 2019-03-08 07:09

Example:

use: android:textStyle="bold"

 <TextView
    android:id="@+id/txtVelocidade"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/txtlatitude"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="34dp"
    android:textStyle="bold"
    android:text="Aguardando GPS"
    android:textAppearance="?android:attr/textAppearanceLarge" />
查看更多
祖国的老花朵
7楼-- · 2019-03-08 07:18

I have a project in which I have the following TextView :

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textStyle="bold"
    android:text="@string/app_name"
    android:layout_gravity="center" 
/>

So, I'm guessing you need to use android:textStyle

查看更多
登录 后发表回答