0

I want to create a setText that derives one textView but contains texts in different textStyle.

For instance, there are some codes below.And, I ask how to use different textStyle's in setText() without working on xml file.

    TextView textView1 = (TextView) findViewById(R.id.textView1);
    textView1.setText("The sum of numbers 1 to " + lastNumber + " is "+ sum);
Fraukn
  • 83
  • 1
  • 2
  • 6

1 Answers1

0

You are exactly searching for this:

Apply two different font styles to a TextView

You can also check this

Is it possible to have multiple styles inside a TextView?

Or if you only want to set one single typeface use this:

    Typeface font = Typeface.createFromAsset(activity.getAssets(),
fonts/androidnation.ttf");
    TextView title .setTypeface(font);

Therefor the font must be in the font folder.

Community
  • 1
  • 1
Bolic
  • 705
  • 2
  • 12
  • 30