user291701
user291701

Reputation: 39721

TextView bold via XML file?

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

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

Thanks

Upvotes: 208

Views: 219252

Answers (6)

Thomas Daniel
Thomas Daniel

Reputation: 257

Use android:textStyle="bold"

4 ways to make Android TextView 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.

Upvotes: 6

param
param

Reputation: 493

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"
/>

Upvotes: 1

Elton da Costa
Elton da Costa

Reputation: 1277

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" />

Upvotes: 10

Sarnath Jegadeesan
Sarnath Jegadeesan

Reputation: 201

use textstyle property as bold

android:textStyle = "bold";

Upvotes: 4

Nguyen  Minh Binh
Nguyen Minh Binh

Reputation: 24443

just use

android:textStyle="bold"

Upvotes: 32

Pascal MARTIN
Pascal MARTIN

Reputation: 401162

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

Upvotes: 510

Related Questions