当前位置: 首页>>代码示例>>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;未经允许,请勿转载。