[Android] Create fonts for text in Android

Firstly we need to have the font file format and copy it to the directory assets
Later in * .java file, use the command Typeface.createFromAsset to set fonts for text.

Example set font for TextView:
file *.xml

fonts in android

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".Font" >

    <TextView
        android:id="@+id/myFont"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="35dp"
        android:text="nguyenvanquan7826"
        android:textColor="#ff0000"
        android:textSize="23sp" />

</RelativeLayout>

file *.java

package VSNet.Test;

import android.os.Bundle;
import android.app.Activity;
import android.graphics.Typeface;
import android.widget.TextView;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		TextView font = (TextView) findViewById(R.id.myFont);
		Typeface myTypeface = Typeface.createFromAsset(getAssets(), "fonts/VALLERGO.otf"); // dat fonts
		font.setTypeface(myTypeface);//kich hoat fonts
	}
}

Result :

fonts android

Download file Demo: Android_Fonts