當前位置: 首頁>>代碼示例>>Java>>正文


Java TextView.getTypeface方法代碼示例

本文整理匯總了Java中android.widget.TextView.getTypeface方法的典型用法代碼示例。如果您正苦於以下問題:Java TextView.getTypeface方法的具體用法?Java TextView.getTypeface怎麽用?Java TextView.getTypeface使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.TextView的用法示例。


在下文中一共展示了TextView.getTypeface方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: AuthorView

import android.widget.TextView; //導入方法依賴的package包/類
public AuthorView(Context context, @Nullable AttributeSet attrs) {
	super(context, attrs);

	LayoutInflater inflater = (LayoutInflater) context
			.getSystemService(LAYOUT_INFLATER_SERVICE);
	inflater.inflate(R.layout.author_view, this, true);

	avatar = (CircleImageView) findViewById(R.id.avatar);
	avatarIcon = (ImageView) findViewById(R.id.avatarIcon);
	authorName = (TextView) findViewById(R.id.authorName);
	authorNameTypeface = authorName.getTypeface();
	date = (TextView) findViewById(R.id.dateView);
	trustIndicator = (TrustIndicatorView) findViewById(R.id.trustIndicator);

	TypedArray attributes =
			context.obtainStyledAttributes(attrs, R.styleable.AuthorView);
	int persona = attributes.getInteger(R.styleable.AuthorView_persona, 0);
	setPersona(persona);
	attributes.recycle();
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:21,代碼來源:AuthorView.java

示例2: replaceFont

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * <p>Replace the font of specified view and it's children</p>
 * @param root The root view.
 * @param fontPath font file path relative to 'assets' directory.
 */
public static void replaceFont(@NonNull View root, String fontPath) {
    if (root == null || TextUtils.isEmpty(fontPath)) {
        return;
    }


    if (root instanceof TextView) { // If view is TextView or it's subclass, replace it's font
        TextView textView = (TextView)root;
        int style = Typeface.NORMAL;
        if (textView.getTypeface() != null) {
            style = textView.getTypeface().getStyle();
        }
        textView.setTypeface(createTypeface(root.getContext(), fontPath), style);
    } else if (root instanceof ViewGroup) { // If view is ViewGroup, apply this method on it's child views
        ViewGroup viewGroup = (ViewGroup) root;
        for (int i = 0; i < viewGroup.getChildCount(); ++i) {
            replaceFont(viewGroup.getChildAt(i), fontPath);
        }
    }
}
 
開發者ID:InnoFang,項目名稱:FamilyBond,代碼行數:26,代碼來源:TypefaceUtil.java

示例3: applyTypeface

import android.widget.TextView; //導入方法依賴的package包/類
public static void applyTypeface(TextView v) {
    if (v.getTypeface() == null) {
        v.setTypeface(getNormal(v.getContext()));
        return;
    }
    switch (v.getTypeface().getStyle()) {
        case Typeface.BOLD:
            v.setTypeface(getNormal(v.getContext()));
            v.getPaint().setFakeBoldText(true);
            break;
        default:
            v.setTypeface(getNormal(v.getContext()));
            break;
        case Typeface.ITALIC:
            v.setTypeface(getNormal(v.getContext()));
            v.getPaint().setTextSkewX(-0.25f);
            break;
        case Typeface.BOLD_ITALIC:
            v.setTypeface(getNormal(v.getContext()));
            v.getPaint().setFakeBoldText(true);
            v.getPaint().setTextSkewX(-0.25f);
            break;
    }

}
 
開發者ID:iPanelkegy,項目名稱:MobileMedia,代碼行數:26,代碼來源:Icon.java

示例4: applyForView

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * Apply typeface to single view
 *
 * @param view      to typeface typeface
 * @param typefaceCollection typeface collection
 */
private static void applyForView(View view, TypefaceCollection typefaceCollection) {

	if (view instanceof TextView) {
		TextView textView = (TextView) view;
		Typeface oldTypeface = textView.getTypeface();
		final int style = oldTypeface == null ? Typeface.NORMAL : oldTypeface.getStyle();
		textView.setTypeface(typefaceCollection.getTypeface(style));
		textView.setPaintFlags(textView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
	}
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:TypefaceHelper.java

示例5: setCustomFont

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * Static method for setting the typeface for the given View
 * The font file should be placed in assets folder in the directory of fonts.
 * Any view that has parent class of TextView can easily use this method.
 *
 * @param view     typeface view
 * @param fontName font name
 */
public static void setCustomFont(View view, String fontName) {
    if (view instanceof TextView) {
        Context context = view.getContext();
        Typeface font = getInstance(context).get(fontName);
        TextView textView = (TextView) view;
        if (textView.getTypeface() != font)
            textView.setTypeface(font);
    }
}
 
開發者ID:EngrAhsanAli,項目名稱:AACustomFont,代碼行數:18,代碼來源:AACustomFont.java


注:本文中的android.widget.TextView.getTypeface方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。