Applies the given Font to the given TextView . - Android User Interface

Android examples for User Interface:TextView

Description

Applies the given Font to the given TextView .

Demo Code


import android.content.Context;
import android.graphics.Typeface;
import android.widget.TextView;

public class Main{
    /**//from   w ww .  ja v a  2 s  . c o m
     * Applies the given {@link Font} to the given {@link TextView}.
     * @param view The {@link TextView} to apply the font to.
     * @param font The {@link Font} to apply.s
     */
    public static void applyFont(TextView view, Font font) {
        view.setTypeface(font.getTypeface(view.getContext()));
    }
    /**
     * Searches the {@link FontMap} for the {@link Typeface} specified by the asset path
     * @param view the {@link TextView} to apply the font to.
     * @param fontAssetPath The asset path containing the font file.
     */
    public static void applyFont(TextView view, String fontAssetPath) {
        view.setTypeface(FontMap.getFontForPath(view.getContext(),
                fontAssetPath));
    }
}

Related Tutorials