I write code and use CompatResources to get font and set as TypeFace to views bug Fabric.io reported some crashes about it .
Caused by android.content.res.Resources$NotFoundException Font resource ID #0x7f090000 could not be retrieved.
and it is my code :
tfFontIcon = ResourcesCompat.getFont(mContext, R.font.font_icon);
thanks for your help.
Try below soultion
Solution 1
Add your font in assets folders like below image
And use below method to set font typeFace
CommonUtils.setFont(context, binding.txtDigital, "Montserrat-Bold.ttf");
public static void setFont(Context context, TextView textView, String fontPath) {
Typeface t = Typeface.createFromAsset(context.getResources().getAssets(), fontPath);
textView.setTypeface(t);
}
Solution 2
Add font folder inside res folder like below image
And directly add font family into your textview
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/app_name"
android:fontFamily="@font/roboto_medium"
android:textColor="@color/black"
android:textSize="@dimen/_20ssp"
android:visibility="gone" />
I hope this can help you!
Thank You.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With