Using custom font in android

Download using custom font in android sample

Android provide few fonts like monospace, normal, sans, serif. What if we want to use some custom font that is not present as part of android font.

Here is easy steps to use custom font:

  1. Download custom font you want to use in otf or ttf format. Make sure extension is in lowercase.
  2. Create assets folder and put that font there either in root or sub-folder.

    To create assets folder, in Android Studio (1.0 & above), right-click on the app and navigate to the Assets Folder.
    Creating assets folder in android studio

    In the next screen, just click on finish button to create assets folder.

  3. onCreate method of activity, set font for your view

Result of sample

Using custom font in android

How to use custom font across the whole application

Android doesn't support for applying fonts across the whole app. Still, there are 4 approach which we can apply to use custom font in whole application with their own pros and cons. These approachs are:

  • Use reflection to change the system font
  • Create and subclass custom View classes for each View that need to use a custom font
  • Implement a View Crawler which traverses the view hierarchy for the current screen
  • Use a 3rd party library.

Example of using custom font demo

Step 1: Create a new project in Android Studio and name it Custom font in android.

Step 2: Open res -> layout -> activity_main.xml and add following code


Step 3: Create assets folder and put your font there

Step 4: Open your and onCreate method set your desired font for view. Source of my is given below:

Step 5: Clean and run the project to see the result.

Share & Like

Tutorial topics

About is for Java, J2ee, Html5 and android developers. All tutorials are well explained and are easy to understand. We have tested every tutorials on our developement environment before posting it in public domain.