Arial font for text in Android

后端 未结 6 1518
悲哀的现实
悲哀的现实 2021-02-20 04:11

I want to show text in Arial font. But Arial font is not available in android system fonts. I don\'t want to use arial ttf file in my application. Is there any other way to appl

6条回答
  •  猫巷女王i
    2021-02-20 04:39

    If the font is not available in the android system, then you have to use the font file to apply that particular font say arial to your textView. May I know why you are not willing to use the font file to apply as it gives the same functionality.

    Sample usage for using the font file is:

    Typeface tfArial = Typeface.createFromAsset(getAssets(), "arial.ttf");
    TextView tv = null;
    // find the textview id from layout or create dynamically
    tv.setTypeface(tfArial);
    

    EDIT:

    You need to put the font file arial.ttf in your asset folder.

提交回复
热议问题