O'Reilly logo

Mastering Android Studio 3 by Kyle Mew

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

XML fonts

As of API level 26, it has been possible to include fonts in a project as XML resources in the res directory. This feature has simplified the task of using nondefault fonts in an application as well as bringing the process into line with other resource management.

Adding XML fonts is remarkably simple, as the following exercise demonstrates:

  1. Right-click on the res directory and select New | Android resource directory.
  2. Select font from the Resource type drop-down and click on OK.
  3. Right-click on the newly created font folder and select Show in Explorer.
  4. Rename your font files so that they only contain permissible characters. For example, times_new_roman.ttf not TimesNewRoman.ttf.
  5. Place your selected fonts in the font directory.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required