Sitemap
Hasper Ong

Hasper Ong

i am mobile developer, i love to share story, and of course i love to write story.

Member-only story

Add Custom Fonts in Android Java

Mar 18, 2024

A custom font for Android refers to using a typeface other than the default system fonts provided by the Android operating system. Android allows developers to incorporate custom fonts into their applications, offering greater flexibility in design and branding.

  1. This is the link to download custom font https://fonts.google.com/selection — the format in ttf
  2. Create font folder in android studio to put custom font ttf format
Press enter or click to view image in full size
Press enter or click to view image in full size

3. Put downloaded ttf file into font folder

4. Use custom font in activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity"
android:gravity="center_vertical">

<TextView
android:layout_margin="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Testing font"
android:fontFamily="@font/courgette_regular"
android:textSize="30dp"/>
</LinearLayout>

5. Result

THE END

--

--

Hasper Ong
Hasper Ong

Written by Hasper Ong

i am mobile developer, i love to share story, and of course i love to write story.