Is there a way to bold the text in a TextView via XML?
<TextView
android:textSize="12dip"
android:textAppearance="bold" -> ??
</TextView>
Thanks
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" .
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 “|” .
Yes, just add android:textStyle="bold|italic" .
SpannableString string = new SpannableString("Bold and italic text"); string. setSpan(new StyleSpan(Typeface. BOLD), 0, 4, Spannable.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With