Some users will land on this page to find instructions on using custom fonts in your xml application. Here is how I did it:
The font resource directory is missing by default. You can create it manually by following the documentation here [too much work]
Or use the font selector from the GUI -
Select the "TextView in Design" tab.
Open the fontFamily xml attribute drop-down list.
Scroll down to "More Fonts".
Select “Downloadable Font” from the popup that appears.
Android Studio will automatically create a font resource directory with the necessary declarations mentioned in the above documentation. After this step, you can copy your own font file (for example myfont.ttf) to the font directory and install the desired font from xml, for example:
<TextView android:fontFamily="@font/myfont" android:id="@+id/aboutus_head_textview" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/who_are_we" />
If you want to use the same font throughout the application, you can set fontFamily to your AppTheme in styles.xml:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <!-- custom font for the entire app --> <item name="fontFamily">@font/myfont</item> </style>
[fontFamily prefix with android: if above doesn't work]
Screenshots:


Note. This answer assumes you are using Android Studio 3+ and supporting the 26+ library version
source share