繁体   English   中英

字体-family roboto android 2.3.3

[英]font -family roboto android 2.3.3

我正在尝试为我的android 2.3应用程序使用roboto字体包,但未添加fomarto字母。 我已经尝试使用以下代码:

 TextView tvTextView =  ( TextView ) findViewById ( R . id . textView1 ); 
 Typeface typeface =  Typeface . createFromAsset ( getAssets (), "Roboto-Black.ttf" ); 
 tvTextView . setTypeface ( typeface );

它不应用字母格式,我该如何旋转信号源roboto android 2.3?

对于API 11,没有其他方法可以执行此操作<在资产中不包含字体文件

使用此TextView代替:

public class TextView_Roboto extends TextView {

    public TextView_Roboto(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
            createFont();
    }

    public TextView_Roboto(Context context, AttributeSet attrs) {
            super(context, attrs);
            createFont();
    }

    public TextView_Roboto(Context context) {
            super(context);
            createFont();
    }

    public void createFont() {
            Typeface font = Typeface.createFromAsset(getContext().getAssets(), "robo_font.ttf");
            setTypeface(font);
    }
 }

在这里看到完整的答案 ...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM