Example usage for android.widget TextView setTypeface

List of usage examples for android.widget TextView setTypeface

Introduction

In this page you can find the example usage for android.widget TextView setTypeface.

Prototype

public void setTypeface(@Nullable Typeface tf) 

Source Link

Document

Sets the typeface and style in which the text should be displayed.

Usage

From source file:Main.java

public static void setFengGe(Context context, TextView tv, String ttf) {
    Typeface fontFace = Typeface.createFromAsset(context.getAssets(), ttf);
    tv.setTypeface(fontFace);
}

From source file:Main.java

public static void setFontAllView(ViewGroup vg) {
    for (int i = 0; i < vg.getChildCount(); ++i) {
        View child = vg.getChildAt(i);

        if (child instanceof ViewGroup) {
            setFontAllView((ViewGroup) child);
        } else if (child != null) {
            Typeface face;//from www . j av  a 2  s .  com
            if (child.getTag() != null && child.getTag().toString().toLowerCase().equals("bold")) {
                face = boldFont;
            } else {
                face = regularFont;
            }

            if (child instanceof TextView) {
                TextView textView = (TextView) child;
                textView.setTypeface(face);
            } else if (child instanceof EditText) {
                EditText editView = (EditText) child;
                editView.setTypeface(face);
            } else if (child instanceof RadioButton) {
                RadioButton radioView = (RadioButton) child;
                radioView.setTypeface(face);
            } else if (child instanceof CheckBox) {
                CheckBox checkboxView = (CheckBox) child;
                checkboxView.setTypeface(face);
            } else if (child instanceof Button) {
                Button button = (Button) child;
                button.setTypeface(face);
            }
        }
    }
}

From source file:Main.java

public static void setFontOnView(AssetManager assets, TextView textView, String fontPath) {
    Typeface quicksandBold = Typeface.createFromAsset(assets, fontPath);
    textView.setTypeface(quicksandBold);
}

From source file:Main.java

public static void setFont(TextView t, String font) {
    Typeface type = Typeface.createFromAsset(t.getContext().getAssets(), font);
    t.setTypeface(type);
}

From source file:Main.java

public static void setLightFontFamily(Context context, TextView view) {
    Typeface tf = Typeface.createFromAsset(context.getAssets(), "Gill Sans/Gill Sans MT Light.ttf");
    view.setTypeface(tf);
}

From source file:Main.java

public static void setFont(TextView textView) {
    Typeface tf = Typeface.createFromAsset(textView.getContext().getAssets(), "font/ProximaNova-Reg.otf");
    textView.setTypeface(tf);
}

From source file:Main.java

/**
 * Sets a determined font on a text view element
 *
 * @param context   Context in which the TextView can be found
 * @param font      Font to be set in the text view see available fonts as static attributes of this class
 * @param textViews TextViews to which the font will be applied
 *///w  ww. j a  v a2 s.  c  om
public static void setTypeface(Context context, String font, TextView... textViews) {
    Typeface tf = Typeface.createFromAsset(context.getAssets(), font);
    for (TextView txt : textViews) {
        txt.setTypeface(tf);
    }
}

From source file:Main.java

public static void applyFont(TextView textView, String fontPath) {
    Typeface fontFace = Typeface.createFromAsset(textView.getContext().getAssets(), fontPath);
    textView.setTypeface(fontFace);
}

From source file:Main.java

public static void setFontFace(TextView v, Context context) {
    if (font == null)
        font = Typeface.createFromAsset(context.getAssets(), "fontawesome-webfont.ttf");
    v.setTypeface(font);
}

From source file:Main.java

private static void setCustomFont(TextView c) {
    Object tag = c.getTag();/*from ww w . j  a  v  a2 s  .com*/
    if (tag instanceof String) {
        if (((String) tag).contains("bold")) {
            c.setTypeface(bold);
            return;
        }
        if (((String) tag).contains("condensed")) {
            c.setTypeface(condensed);
            return;
        }
        if (((String) tag).contains("light")) {
            c.setTypeface(light);
            return;
        }
    }
    c.setTypeface(normal);
}