Text Font add Android Example kotlin

01-Jan-2025

Text Font add Android Example kotlin


1/  Create a font directory under the res directory and paste your fonts here.

      res --> font 


Fonts Downloaded From: https://fonts.google.com/



2/ Modify your activity_main.xml


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

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Spicy rice font is used in this text"
android:textSize="28dp"
android:textColor="@color/black"
android:fontFamily="@font/spicyrice_regular" />



<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bebas font is used in this text"
android:textSize="35dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:textColor="@color/black"
android:fontFamily="@font/bebasneue_regular" />



<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dancing Script font is used in this text"
android:textSize="27dp"
android:textColor="@color/black"
android:fontFamily="@font/dancingscript_variablefont_wght" />

</LinearLayout>




Output:


Comments