With Android 8.0 using Custom Fonts in Application became easy with downloadable fonts
.
We can add fonts directly to the res/font/ folder
in the project folder, and in doing so, the fonts become automatically available in Android Studio.
Now set fontFamily
attribute to list of fonts or click on more and select font of your choice. This will add tools:fontFamily="@font/your_font_file"
line to your TextView.
This will Automatically generate few files.
1. In values folder it will create fonts_certs.xml
.
2. In Manifest it will add this lines:
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
3.
preloaded_fonts.xml
<resources>
<array name="preloaded_fonts" translatable="false">
<item>@font/open_sans_regular</item>
<item>@font/open_sans_semibold</item>
</array>
</resources>