Last Update November 6, 2020: We improved the overall article.

Fonts make the app look great with other UI elements but an obvious thing is that android provide not more fonts for your project so you need to add external fonts to your projects.
In this example i will show how to add fonts to your android studio project.

How to include fonts in android application 1

Start New Project or Existing Project :

Select [Assets] Folder In your project
Create a folder call [fonts] in the [Assets] Directory copy the external fonts in this newly create fonts folder see look image blow:

How to include fonts in android application 2

Create or Open your existing main.xml
Create TextView Inside LinerLayout Section Looks Like :

How to include fonts in android application 3

Now Finally open your MainActivity.class file and try following code. In the following code i am importing font from assets folder and using TypeFace class i am applying custom font on textview label.

import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;
Advertisment

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// Font path
String fontPath = “fonts/Externalfont.ttf”;

// text view label
TextView txtGhost = (TextView) findViewById(R.id.ghost);

// Loading Font Face
Typeface tf = Typeface.createFromAsset(getAssets(), fontPath);

// Applying font
txtExternalfont.setTypeface(tf);
}

Conclusion

In this article to including front this an example to how insert front in my way . if you think there is another way to include the front than you should share you idea here to help me & others.

Advertisement
Previous articleHow To Add Google Play Services In Android Studio
Next articleInstall the Google Play Services SDK In Android Studio
Abdullah Al Mahamud has always been fascinated by the world and is a writer because he wants to share her love of travel with others. He has written for thedevline since 2016, specializing in modern real-life writing about fashion, arts & culture, technology tips, and more! When not writing articles for us at The dev line (which doesn't happen often!), he enjoys exploring both scenic beauty around the globe as well as intellectual topics that help other people become happier. like productivity hacks or ways to save on your grocery bill.