繁体   English   中英

为什么TextInputEditText会产生此错误?

[英]Why is TextInputEditText producing this error?

我一直在尝试将应用程序的fontfamily更改为fontfamily Pro。 问题是只有我的textinputedittext产生此错误

java.lang.RuntimeException: Font not found C:\Users\owner\AndroidStudioProjects\Application\app\src\main\res\font\advent_pro_medium.ttf

在按钮和textviews上一切正常。 我也尝试过使用edittext ,它不会产生此错误,但是不会应用fontfamily 我的字体与错误指出的目录完全相同,那么为什么textinputedittext产生此错误? 下面是我的textinputedittext的代码。

<android.support.design.widget.TextInputEditText
        android:id="@+id/etJoinCode"
        android:layout_width="match_parent"
        android:layout_height="35dp"
        android:fontFamily="@font/advent_pro"
        android:hint="@string/join_code"
        android:textColor="#ffff"
        android:textColorHint="#ffff"
        android:textSize="14sp" />

在您的xml代码中删除android:fontFamily="@font/advent_pro"

1.在assets目录中创建一个新的fonts目录,并将advent_pro_medium.ttf字体文件放在此处。

2.您可以更改为此。

Typeface tf = Typeface.createFromAsset(v.getContext().getAssets(), "fonts/advent_pro_medium.ttf");
etJoinCode.setTypeface(tf);

暂无
暂无

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

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