Custom Fonts in Android Projects (CFAP)

Since android 8.0 (API level 26), has introduced a new feature, namely custom font in XML, where we will use font files in * ttf  or * otf format  as font sources that we put in the font resource package. Later we can call it in the XML Layout by way  @font/yourfont or can also be called in the Java code by way  R.font.yourfont.

Font folders can be created in the following way.

  1. Right click the  res folder  > click New >  Android resource directory
  2. Adjust the form contents as shown in the image below, then click OK.

How to Customize Android App Project Fonts

The file structure of your fonts will look something like the image below. You can also preview the style of each font by double-clicking the font file.

preview font file

Good luck!


Post a Comment

Previous Next

نموذج الاتصال