Current Android Release version:
Version Code: Pie
Version: 9
API level: 28

Android: Working with Fonts

Fonts feature can be used from Android O version. You can create "font" folder in resources folder of your application. Below Font features are providing in Android O release.

  • Fonts in XML
  • System Fonts

Fonder name in Android application: res/font/

Adding the font files in the resource directory

Using Fonts in XML file:
<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="@font/lobster"/>

Using Fonts Programatically:
Typeface typeface = getResources().getFont(R.font.myfont);
textView.setTypeface(typeface);
Retrieving System Fonts:
FontManager fontManager = context.getSystemService(FontManager.class);
FontConfig systemFontsData = fontManager.getSystemFonts();

For more information, Check in official Android developer documentation.
https://developer.android.com/preview/features/working-with-fonts.html

1 comment: