You can create a custom FontTextView :
-Add this custom FontTextView in src package:
package com.example.android.ui;
import android.content.Context;
import android.content.res.AssetManager;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;
import java.util.HashMap;
import java.util.Map;
public class FontTextView extends TextView {
private static Map<String, Typeface> mTypefaces;
public FontTextView(final Context context) {
this(context, null);
}
public FontTextView(final Context context, final AttributeSet attrs) {
this(context, attrs, 0);
}
public FontTextView(final Context context, final AttributeSet attrs, final int defStyle) {
super(context, attrs, defStyle);
if (mTypefaces == null) {
mTypefaces = new HashMap<String, Typeface>();
}
final TypedArray array = context.obtainStyledAttributes(attrs, styleable.FontTextView);
if (array != null) {
final String typefaceAssetPath = array.getString(
R.styleable.FontTextView_customTypeface);
if (typefaceAssetPath != null) {
Typeface typeface = null;
if (mTypefaces.containsKey(typefaceAssetPath)) {
typeface = mTypefaces.get(typefaceAssetPath);
} else {
AssetManager assets = context.getAssets();
typeface = Typeface.createFromAsset(assets, typefaceAssetPath);
mTypefaces.put(typefaceAssetPath, typeface);
}
setTypeface(typeface);
}
array.recycle();
}
}
}
-In res/values add the tt_attrs.xml
<resources>
<declare-styleable name="FontTextView">
<attr name="customTypeface" format="string" />
</declare-styleable>
</resources>
-In your layout which you want add font textview:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:geekui="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.example.android.ui.FontTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textSize="30sp"
geekui:customTypeface="fonts/segoeui.ttf" />
<com.entreprise.android.ui.FontTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="@string/app_name"
geekui:customTypeface="fonts/Times New Roman.ttf" />
<com.entreprise.android.ui.FontTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="@string/app_name"
geekui:customTypeface="fonts/arial unicode ms.ttf" />
</LinearLayout>
all this source code is inspired from https://github.com/ragunathjawahar/android-typeface-textview