anitstudent
anitstudent

Reputation: 19

Why is TextInputEditText producing this error?

I've been trying to change the fontfamily of my application to advent pro. The problem is only my textinputedittext produces this error

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. I've also tried using edittext, it does not produce this error but the fontfamily doesn't get applied. I have my font in the exact same directory that the error states, so why is textinputedittext producing this error? Below is the code of my 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" />

Upvotes: 0

Views: 59

Answers (1)

KeLiuyue
KeLiuyue

Reputation: 8237

Remove android:fontFamily="@font/advent_pro" in your xml code .

1.create a new fonts directory in the assets directory and put the advent_pro_medium.ttf font file here.

2.You can change to this .

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

Upvotes: 1

Related Questions