【问题标题】:font -family roboto android 2.3.3字体-family roboto android 2.3.3
【发布时间】:2014-10-12 14:39:45
【问题描述】:

我正在尝试为我的 android 2.3 应用程序使用机器人字体包,但它没有添加 fomarto 字母。我已经尝试过使用此代码:

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

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

【问题讨论】:

  • 您是否在资产中包含 Roboto-Black.ttf 文件?

标签: android font-family


【解决方案1】:

对于 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);
    }
 }

see full answer here...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-07
    • 1970-01-01
    • 2016-12-01
    • 2012-02-14
    • 2017-01-17
    • 2015-06-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多