Html in text view with different fonts for bold and italic

前端 未结 4 1230
忘掉有多难
忘掉有多难 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:16

    This link will help you to see how to customize android font: http://mobile.tutsplus.com/tutorials/android/customize-android-fonts/

    In which concerns how to apply those font files to the textview, you need to integrate them first in your project:

    Typeface tf = Typeface.createFromAsset(this.getAssets(),
            "fonts/xxx.TTF");
    txt1.setTypeface(tf);
    

    The ttf file should be placed in --> assets/fonts/xxx.TTF

    All needed details are in the paragraph: "Using Custom Fonts"

提交回复
热议问题