How do you change text to bold in Android?


Question

How do you change text/font settings in an Android TextView? For example, how do you make the text bold?

1
394
2/24/2016 7:25:07 AM

To do this in the layout.xml file:

android:textStyle

Examples:

android:textStyle="bold|italic"

Programmatically the method is:

setTypeface(Typeface tf)

Sets the typeface and style in which the text should be displayed. Note that not all Typeface families actually have bold and italic variants, so you may need to use setTypeface(Typeface, int) to get the appearance that you actually want.

512
11/15/2017 5:15:47 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon