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.

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:

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

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;

@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.

SHARE
Previous articleHow To Add Google Play Services In Android Studio
Next articleInstall the Google Play Services SDK In Android Studio

Abdullah Al Mahamud is a programmer and founder of Thedevline an Inspiration blog since 2014. live in Bangladesh. He is passionate about Technology and Design. He works on the freelancing marketplace as a freelancer and has also written for Useful Article in this blog

Leave a Reply

avatar
  Subscribe  
Notify of