Apply multiple style on TextView

462 views Asked by At

I want to apply multiple text-style on textview programmatically in android.

val myView : TextView = findViewById(R.id.date_title)

// now I want to apply - Bold & italic style on myView at same time like we can do in XML file e.g android:textStyle="bold|italic"

myView.setTypeface(null, Typeface.BOLD)

myView.setTypeface(null, Typeface.ITALIC)

But as result I get only italic name how I will get both at same time

2

There are 2 answers

0
Hardik Mehta On

You can follow this link : How to set the font style to bold, italic and underlined in an Android TextView?

Or you can try this myView.setTypeface(null, Typeface.BOLD_ITALIC);

or appy directly in XML file as well:

android:textStyle="bold|italic"
0
Isha Narola On

you can as well use attributes ,in this use text-style attributes and go inside there will be checkbox for normal, bold, italic. If you want to that font is bold as well as italic then check it and make it true .It will work easily.