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


Java Typeface.createFromAsset方法代碼示例

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


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

示例1: getFont

import android.graphics.Typeface; //導入方法依賴的package包/類
public static Typeface getFont(Context context, String fullName) {
    if (storage == null) {
        storage = new HashMap<String, Typeface>();
    }
    synchronized (storage) {
        Typeface font = storage.get(fullName);
        if (font == null) {
            font = Typeface.createFromAsset(context.getAssets(), fullName);
            if (font != null) {
                storage.put(fullName, font);
                return font;
            }
        } else {
            return font;
        }
    }
    return Typeface.DEFAULT;
}
 
開發者ID:WorldBank-Transport,項目名稱:RoadLab-Pro,代碼行數:19,代碼來源:FontsStorage.java

示例2: getIconFont

import android.graphics.Typeface; //導入方法依賴的package包/類
public static Typeface getIconFont() {
    if (iconFont == null) {
        synchronized (Typeface.class) {
            if (iconFont == null) {
                iconFont = Typeface.createFromAsset(sApplication.getAssets(), "iconfont.ttf");
            }
        }
    }
    return iconFont;
}
 
開發者ID:weexext,項目名稱:ucar-weex-core,代碼行數:11,代碼來源:UWXApplication.java

示例3: init

import android.graphics.Typeface; //導入方法依賴的package包/類
private void init(AttributeSet attrs) throws TypeFacedException {
    if (attrs!=null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TypeFacedSwitch);
        String fontName = a.getString(R.styleable.TypeFacedSwitch_switch_font);
        if (fontName!=null) {
            try {
                Typeface myTypeface = Typeface.createFromAsset(context.getAssets(), "fonts/" + fontName);
                setTypeface(myTypeface);
            } catch (Exception e){
                throw new TypeFacedException("Font not found exceptiom");
            }
        }
        a.recycle();
    }
}
 
開發者ID:ChathuraHettiarachchi,項目名稱:TypeFaced,代碼行數:16,代碼來源:TypeFacedSwitch.java

示例4: onCreate

import android.graphics.Typeface; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	super.onCreate(savedInstanceState);
	setContentView(R.layout.addtocontactlist);
	roboto = Typeface.createFromAsset(getAssets(), "font/Roboto-Regular.ttf");
	android = Typeface.createFromAsset(getAssets(), "font/android.ttf");
	initialise();
}
 
開發者ID:mityung,項目名稱:XERUNG,代碼行數:11,代碼來源:AddToContactList.java

示例5: init

import android.graphics.Typeface; //導入方法依賴的package包/類
private void init(Context context ,AttributeSet attrs) {
    if (attrs!=null) {
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.FontTextView);
        String fontName = a.getString(R.styleable.FontTextView_fontName);
        if (fontName!=null) {
            Typeface myTypeface = Typeface.createFromAsset(getContext().getAssets(), "fonts/"+fontName);
            setTypeface(myTypeface);
            //setAllCaps(false);
        }
        a.recycle();
    }
}
 
開發者ID:Manuaravind1989,項目名稱:FontUtils,代碼行數:13,代碼來源:FontButton.java

示例6: PartShowAdapter

import android.graphics.Typeface; //導入方法依賴的package包/類
/**
 * Constructor for part show adapter
 *
 * @param context Application context
 * @param items   list of sora
 */
public PartShowAdapter(Context context, List<Sora> items) {
    this.context = context;
    this.items = items ;
    customFont = Typeface.createFromAsset(context.getAssets(), "simple.otf");
    isTabletDevice = isTablet(context);
}
 
開發者ID:fekracomputers,項目名稱:QuranAndroid,代碼行數:13,代碼來源:PartShowAdapter.java

示例7: setTypeface

import android.graphics.Typeface; //導入方法依賴的package包/類
public void setTypeface(String textFontPath) {
    if (!TextUtils.isEmpty(textFontPath)) {
        Typeface typeFace =
            Typeface.createFromAsset(getContext().getApplicationContext().getAssets(), textFontPath);
        message.setTypeface(typeFace);
    }
}
 
開發者ID:minube,項目名稱:Text-Length-Bar,代碼行數:8,代碼來源:TextLengthBar.java

示例8: getTypeface

import android.graphics.Typeface; //導入方法依賴的package包/類
/**
 * Get the cached typeface
 *
 * @param fontName fontname, make sure you have this font in in assets
 * @param context  Context
 * @return cached font, null in case of any error
 */
public static Typeface getTypeface(String fontName, Context context) {
    Typeface typeface = sFontCache.get(fontName);
    if (typeface == null) {
        try {
            typeface = Typeface.createFromAsset(context.getAssets(), fontName);
        } catch (Throwable e) {
            return null;
        }
        sFontCache.put(fontName, typeface);
    }
    return typeface;
}
 
開發者ID:yajnesh,項目名稱:AndroidGeneralUtils,代碼行數:20,代碼來源:FontCache.java

示例9: QuartersShowAdapter

import android.graphics.Typeface; //導入方法依賴的package包/類
public QuartersShowAdapter(Context context, List<Quarter> items) {
    isTabletDevice = isTablet(context);
    this.context = context;
    this.items = items ;
    customFont = Typeface.createFromAsset(context.getAssets(), "simple.otf");
    DatabaseAccess databaseAccess = new DatabaseAccess();
    for (Quarter quarter: items) {
        if(quarter.ayaFirstNumber==0){
            quarter.firstVerseText = databaseAccess.getSoraFirstAya(quarter.soraid);
        }
    }
}
 
開發者ID:fekracomputers,項目名稱:QuranAndroid,代碼行數:13,代碼來源:QuartersShowAdapter.java

示例10: getTypeFaceFromAssets

import android.graphics.Typeface; //導入方法依賴的package包/類
@Override
@Nullable
public Typeface getTypeFaceFromAssets(final String fontFilePath) {
    try {
        return Typeface.createFromAsset(mContext.getAssets(), fontFilePath);
    } catch (RuntimeException e) {
        Log.e(DefaultTypeFaceProvider.class.getName(), e.getMessage());
    }
    return null;
}
 
開發者ID:myntra,項目名稱:CoachMarks,代碼行數:11,代碼來源:DefaultTypeFaceProvider.java

示例11: setCustomFont

import android.graphics.Typeface; //導入方法依賴的package包/類
public boolean setCustomFont(Context ctx, String asset) {
    Typeface tf = null;
    try {
        tf = Typeface.createFromAsset(ctx.getAssets(), asset);
    } catch (Exception e) {
        Log.e(TAG, "Could not get typeface: "+e.getMessage());
        return false;
    }

    setTypeface(tf);
    return true;
}
 
開發者ID:salesforce-ux,項目名稱:design-system-android,代碼行數:13,代碼來源:TypeFaceTextView.java

示例12: getSourceCodePro

import android.graphics.Typeface; //導入方法依賴的package包/類
public Typeface getSourceCodePro() {
    return Typeface.createFromAsset(assetManager, "fonts/Source_Code_Pro.ttf");
}
 
開發者ID:Light-Team,項目名稱:ModPE-IDE-Source,代碼行數:4,代碼來源:TypefaceManager.java

示例13: onCreate

import android.graphics.Typeface; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    
    db = new DatabaseHandler(this);
    
    dataIta = cursorToArray(db.getData("Ita"));
    dataEng = cursorToArray(db.getData("Eng"));
    
    btnAddFav = (StarView) findViewById(R.id.btnAddFav);
    btnCheckFav = (StarView) findViewById(R.id.btnCheckFav);
    
    fontReg = Typeface.createFromAsset(getAssets(), "fonts/ZillaSlab-Regular.ttf");
    fontIta = Typeface.createFromAsset(getAssets(), "fonts/ZillaSlab-Italic.ttf");
    fontBold = Typeface.createFromAsset(getAssets(), "fonts/ZillaSlab-Bold.ttf");

    tvTitle = (TextView) findViewById(R.id.tvTitle);
    tvTitle.setTypeface(fontBold);
    
    btnInfo = (ToggleButton) findViewById(R.id.btnInfo);
    
    tvIta = (TextView) findViewById(R.id.tvIta);
    tvIta.setTypeface(fontIta);
    
    tvEng = (TextView) findViewById(R.id.tvEng);
    tvEng.setTypeface(fontReg);
    
    tvMain = (TextView) findViewById(R.id.tvMain);

    btnInfo.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                tvMain.setVisibility(View.INVISIBLE);
                btnAddFav.setVisibility(View.INVISIBLE);
                showInfo();
            } else {
                tvMain.setVisibility(View.VISIBLE);
                btnAddFav.setVisibility(View.VISIBLE);
                changeSays();
            }
        }
    });

    tvMain.setOnTouchListener(new OnSwipeTouchListener(MainActivity.this) {
        @Override
        public void onSwipeRight() {changeSays(); }
        @Override
        public void onSwipeLeft() { changeSays(); }
    });

    changeSays();
}
 
開發者ID:francescosoave,項目名稱:TIS_android,代碼行數:54,代碼來源:MainActivity.java

示例14: getCustomTypeface

import android.graphics.Typeface; //導入方法依賴的package包/類
private Typeface getCustomTypeface(@NonNull String fontPath) {
  return Typeface.createFromAsset(getContext().getAssets(), fontPath);
}
 
開發者ID:mityung,項目名稱:XERUNG,代碼行數:4,代碼來源:MaterialMultiAutoCompleteTextView.java

示例15: getThinFont

import android.graphics.Typeface; //導入方法依賴的package包/類
public Typeface getThinFont(){
    return Typeface.createFromAsset(context.getAssets(), context.getString(R.string.font_thin));
}
 
開發者ID:afiqiqmal,項目名稱:MVP-Android,代碼行數:4,代碼來源:TypeFaceUtils.java


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