Using custom font for your app in android studio - puru world official

Using custom font for your app in android studio

Mar 16, 2018 1 min read ... views
Advertisement



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="androidapp.puruworld.customfont.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="@font/dancingscriptregular"
        android:text="Hello World!"
        android:textSize="50sp"
        android:layout_gravity="center"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="@font/gloriahallelujah"
        android:text="Hello World!"
        android:textSize="50sp"
        android:layout_gravity="center"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />


    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="@font/rammettooneregular"
        android:text="Hello World!"
        android:textSize="50sp"
        android:layout_gravity="center"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</LinearLayout>



MainActivity.java

package androidapp.puruworld.customfont;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}





android custom font family,
android studio font family,
custom font android xml,
add font to android studio,
android custom font for whole application,
android custom font style xml,
how to change font style in android xml,
android fonts list,
Advertisement
P

Written by Puru

I am a software builder, developer, and technical writer. I design web products like JSON2Apex and the Python Visualizer. I write these guides to share actual, real-world development solutions and lifestyle strategies. No corporate fluff, just practical code and direct insights.

Need help? Ask our AI guide! 👋