Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 243
user291701 Avatar asked Oct 07 '22 18:10

user291701


People also ask

How do I make TextView bold in XML?

Change Text Style of TextView to BOLD in XML Layout File textStyle attribute of TextView widget accepts on of these values: "bold" , "italic" or "normal" . To change the style to bold, you have to assign textStyle with "bold" .

How do I set TextView to bold?

android:textStyle attribute is the first and one of the best way to make the text in TextView bold. just use “bold”. If you want to use bold and italic. Use pipeline symbol “|” .

How do you bold and italicize text in XML?

Yes, just add android:textStyle="bold|italic" .

How do I make bold text in Spannable?

SpannableString string = new SpannableString("Bold and italic text"); string. setSpan(new StyleSpan(Typeface. BOLD), 0, 4, Spannable.


1 Answers

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

like image 502
Pascal MARTIN Avatar answered Oct 10 '22 08:10

Pascal MARTIN