Home > Mobile >  Apply multiple style on TextView
Apply multiple style on TextView

Time:06-30

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

CodePudding user response:

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"

CodePudding user response:

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.

  • Related