【问题标题】:Android java.lang.RuntimeException: native typeface cannot be madeAndroid java.lang.RuntimeException:无法制作原生字体
【发布时间】:2016-04-29 02:31:26
【问题描述】:

尝试为按钮设置自定义字体时出现以下异常:java.lang.RuntimeException: native typeface cannot be made 我已经看过类似的问题,但他们的解决方案都没有奏效。

我的字体在 src/main 里面,文件结构看起来还不错。

这是文件结构:

这里是代码:

private void generateButtonListener(final Button btn,final String inputText) {

    btn.setTypeface(Typeface.createFromAsset(getAssets(), "rb.ttf"));

    btn.setOnClickListener(new android.view.View.OnClickListener() {
        public void onClick(View view1) {
            getCurrentInputConnection().commitText(inputText,1);
        }

    });


}

不确定是否重要,但我正在制作自定义键盘应用程序,因此我在 onCreateInputView 方法中的按钮上设置了此侦听器。像这样:

   @Override
public View onCreateInputView() {

    LayoutInflater lInflate = getLayoutInflater();
    Resources res = getResources();
    LinearLayout inputView = (LinearLayout) lInflate.inflate(R.layout.copypasta, null);
    Button tab_navySeal = (Button) inputView.findViewById(R.id.tab_navySeal);
  Button nSeal_1 = (Button) btnset_navyseal.findViewById(R.id.nSeal_1);
        generateButtonListener(nSeal_1, res.getString(R.string.NStxt));

等等……

我似乎遵守了所有字体规则,有什么问题?

【问题讨论】:

    标签: android android-fonts


    【解决方案1】:

    你是把字体用作库还是

    btn.setTypeface(Typeface.createFromAsset(getAssets(), "rb.ttf"));

    rb.ttf是破旧的路径吗?试试fonts/rb.ttf

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-11
      • 1970-01-01
      • 1970-01-01
      • 2011-11-23
      • 2014-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多