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
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.