本文整理汇总了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;
}
示例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;
}
示例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();
}
}
示例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();
}
示例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();
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例12: getSourceCodePro
import android.graphics.Typeface; //导入方法依赖的package包/类
public Typeface getSourceCodePro() {
return Typeface.createFromAsset(assetManager, "fonts/Source_Code_Pro.ttf");
}
示例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();
}
示例14: getCustomTypeface
import android.graphics.Typeface; //导入方法依赖的package包/类
private Typeface getCustomTypeface(@NonNull String fontPath) {
return Typeface.createFromAsset(getContext().getAssets(), fontPath);
}
示例15: getThinFont
import android.graphics.Typeface; //导入方法依赖的package包/类
public Typeface getThinFont(){
return Typeface.createFromAsset(context.getAssets(), context.getString(R.string.font_thin));
}