set Font For TextView - Android User Interface

Android examples for User Interface:TextView

Description

set Font For TextView

Demo Code


//package com.java2s;
import android.content.Context;
import android.graphics.Typeface;

import android.widget.TextView;

public class Main {
    public static void setFontForTextView(Context context,
            TextView textView, int resId) {
        setFontFotTextView(context, textView, context.getString(resId));
    }// www  .  j ava2s. c  o m

    public static void setFontFotTextView(Context context,
            TextView textView, String assetsFontName) {
        Typeface tf = Typeface.createFromAsset(context.getAssets(),
                assetsFontName);
        textView.setTypeface(tf);
    }
}

Related Tutorials