Html in text view with different fonts for bold and italic

前端 未结 4 1255
忘掉有多难
忘掉有多难 2021-01-05 03:46

I\'m trying to use a custom font on a TextView. The TextView text is set with textView1.setText(Html.fromHtml(htmlText));

The

4条回答
  •  失恋的感觉
    2021-01-05 04:07

    Have you try with applying that all font to same textView's text one by one. I think with that you can apply the more more effect to same TextView.

    Milos's code is right. In addition i have puted my own explaination. You can add your fonts in to the assets foldera and after that you can apply that font to the textView one-by-one.

    Not sure but might be useful to you.

    My Code:

    Typeface font1 = Typeface.createFromAsset(getAssets(), "YOUR_FONT1.ttf");
    Typeface font2 = Typeface.createFromAsset(getAssets(), "YOUR_FONT2.ttf");
    Typeface font3 = Typeface.createFromAsset(getAssets(), "YOUR_FONT3.ttf");
    
    chips_text.setTypeface(font1);
    chips_text.setTypeface(font2);
    chips_text.setTypeface(font3);
    

    Feel free to comment and queries.

提交回复
热议问题