[英]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.