This question has already been answered:

How to connect fonts to android?

Reported as a duplicate by participants of Yura Ivanov , Kromster , Denis , user194374, pavel 27 Dec '16 at 20:56 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

    2 answers 2

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

    But it should be borne in mind that referring to the assets folder every time is an "expensive" operation, so I advise you to create a singleton class that will store links to already connected fonts. Or use the Calligraphy library, which already does all this for you. Here is a good article on how to connect fonts

    • I connect via xml, The problem is in older versions of android, the application is undermining. Is it because I'm constantly pulling from assets? - OPTIMIST .KZ
     TextView tv = (TextView) findViewById(R.id.appname); Typeface face = Typeface.createFromAsset(getAssets(), "fonts/epimodem.ttf"); tv.setTypeface(face); 

    In the assets folder, put your epimodem.ttf font

    • I connect via xml, here's an example: <com.saabr.administrator.enbekkz.myservice_classes.api_classes.TextViewPlus foo: customFont = "myfont.ttf" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: text = " Log in "android: textColor =" # fff "android: textSize =" 20dp "android: layout_gravity =" center "android: id =" @ id + open "/> - OPTIMIST .KZ
    • The problem is in older versions of androd, the application is undermining - OPTIMIST .KZ
    • one
      So you probably don’t cache it, but every time it accesses the assets folder. Take advantage of the library, there is little business there at all - pavel163
    • Thanks for the professional answer! - OPTIMIST .KZ