How to use custom font in Android Studio

How to use custom font in Android Studio


  1. Go to the (project folder)
  2. Then app>src>main
  3. Create folder 'assets>fonts' into the main folder.
  4. Put your .ttf file into the fonts folder.
        AssetManager am = context.getApplicationContext().getAssets();
    
        typeface = Typeface.createFromAsset(am,
                String.format(Locale.US, "fonts/%s", "abc.ttf"));
    
        setTypeface(typeface);
    or try this way:
       TextView tx = (TextView)findViewById(R.id.textview1);
    
       Typeface custom_font = Typeface.createFromAsset(getAssets(),  "fonts/abc.ttf");
    
       tx.setTypeface(custom_font);


EmoticonEmoticon