Here you can find the source of setTypeface(Context context, String font, TextView... textViews)
Parameter | Description |
---|---|
context | Context in which the TextView can be found |
font | Font to be set in the text view see available fonts as static attributes of this class |
textViews | TextViews to which the font will be applied |
public static void setTypeface(Context context, String font, TextView... textViews)
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.graphics.Typeface; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; public class Main { /**//from ww w.ja v a 2 s. c o m * 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 style * {@see Typeface} * @param textViews * TextViews to which the font will be applied */ public static void setTypeface(Context context, String font, int style, TextView... textViews) { Typeface tf = Typeface.createFromAsset(context.getAssets(), font); for (TextView txt : textViews) { txt.setTypeface(tf, style); } } /** * 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 */ public static void setTypeface(Context context, String font, TextView... textViews) { Typeface tf = Typeface.createFromAsset(context.getAssets(), font); for (TextView txt : textViews) { txt.setTypeface(tf); } } /** * Sets a determined font on a button element view * * @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 buttons * Buttons to which the font will be applied */ public static void setTypeface(Context context, String font, Button... buttons) { Typeface tf = Typeface.createFromAsset(context.getAssets(), font); for (Button txt : buttons) { txt.setTypeface(tf); } } /** * 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 style * {@see Typeface} * @param buttons * Buttons to which the font will be applied */ public static void setTypeface(Context context, String font, int style, Button... buttons) { Typeface tf = Typeface.createFromAsset(context.getAssets(), font); for (Button txt : buttons) { txt.setTypeface(tf, style); } } /** * 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 style * {@see Typeface} * @param group * Root layout in which TextView and Buttons will be searched to apply the font */ public static void setTypeface(Context context, String font, int style, ViewGroup group) { Typeface tf = Typeface.createFromAsset(context.getAssets(), font); int count = group.getChildCount(); View v; for (int i = 0; i < count; i++) { v = group.getChildAt(i); if (v instanceof TextView) ((TextView) v).setTypeface(tf, style); else if (v instanceof ViewGroup) setTypeface(context, font, style, (ViewGroup) v); } } /** * 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 group * Root layout in which TextView and Buttons will be searched to apply the font */ public static void setTypeface(Context context, String font, ViewGroup group) { Typeface tf = Typeface.createFromAsset(context.getAssets(), font); int count = group.getChildCount(); View v; for (int i = 0; i < count; i++) { v = group.getChildAt(i); if (v instanceof TextView) ((TextView) v).setTypeface(tf); else if (v instanceof ViewGroup) setTypeface(context, font, (ViewGroup) v); } } }