How to set TextView textStyle such as bold, italic How to set TextView textStyle such as bold, italic android android

How to set TextView textStyle such as bold, italic


textView.setTypeface(null, Typeface.BOLD_ITALIC);textView.setTypeface(null, Typeface.BOLD);textView.setTypeface(null, Typeface.ITALIC);textView.setTypeface(null, Typeface.NORMAL);

To keep the previous typeface

textView.setTypeface(textView.getTypeface(), Typeface.BOLD_ITALIC)


Try this to set on TextView for bold or italic

textView.setTypeface(textView.getTypeface(), Typeface.BOLD);textView.setTypeface(textView.getTypeface(), Typeface.ITALIC);textView.setTypeface(textView.getTypeface(), Typeface.BOLD_ITALIC);


Programmatically:

You can do programmatically using setTypeface():

textView.setTypeface(null, Typeface.NORMAL);      // for Normal TexttextView.setTypeface(null, Typeface.BOLD);        // for Bold onlytextView.setTypeface(null, Typeface.ITALIC);      // for ItalictextView.setTypeface(null, Typeface.BOLD_ITALIC); // for Bold and Italic

XML:

You can set Directly in XML file in <TextView /> like:

android:textStyle="normal"android:textStyle="normal|bold"android:textStyle="normal|italic"android:textStyle="bold"android:textStyle="bold|italic"