简体   繁体   English

为什么TextInputEditText会产生此错误?

[英]Why is TextInputEditText producing this error?

I've been trying to change the fontfamily of my application to advent pro. 我一直在尝试将应用程序的fontfamily更改为fontfamily Pro。 The problem is only my textinputedittext produces this error 问题是只有我的textinputedittext产生此错误

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

Everything works fine on buttons and textviews . 在按钮和textviews上一切正常。 I've also tried using edittext , it does not produce this error but the fontfamily doesn't get applied. 我也尝试过使用edittext ,它不会产生此错误,但是不会应用fontfamily I have my font in the exact same directory that the error states, so why is textinputedittext producing this error? 我的字体与错误指出的目录完全相同,那么为什么textinputedittext产生此错误? Below is the code of my 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" />

Remove android:fontFamily="@font/advent_pro" in your xml code . 在您的xml代码中删除android:fontFamily="@font/advent_pro"

1.create a new fonts directory in the assets directory and put the advent_pro_medium.ttf font file here. 1.在assets目录中创建一个新的fonts目录,并将advent_pro_medium.ttf字体文件放在此处。

2.You can change to this . 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