Use external fonts in android

后端 未结 6 1485
被撕碎了的回忆
被撕碎了的回忆 2020-11-27 13:31

I want to use external fonts in my app. I have tried adding new fonts using AssetManager but it did not work. Below is my code:

Typ         


        
6条回答
  •  日久生厌
    2020-11-27 14:17

    In order to access our font easily, we need to bundle it with our application in a way that our code can subsequently load it. To do this, we create a Fonts folder in our assets direct

    This may be your .xml

    
    
    
        
    

    Write following code in your .java class

    Typeface tf = Typeface.createFromAsset(getAssets(),
                "fonts/BPreplay.otf");
        TextView tv = (TextView) findViewById(R.id.CustomFontText);
        tv.setTypeface(tf);
    

提交回复
热议问题