Since you are using a support library, use ResourceCompat
Typeface typeFace= ResourcesCompat.getFont(getActivity(),R.font.roboto);
This will fix your problem.
If you want to support api level 26 and above, you can use
Typeface typeface = getResources().getFont(R.font.myfont);
j doe
source share