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.
- Right click the res folder > click New > Android resource directory
- Adjust the form contents as shown in the image below, then click OK.
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.
Good luck!