Android Typeface createFromAsset
You can use your View‘s getContext() method to get the current Context, then use it to get the assets: Typeface font = Typeface.createFromAsset(getContext().getAssets(), “robotobold.ttf”);
You can use your View‘s getContext() method to get the current Context, then use it to get the assets: Typeface font = Typeface.createFromAsset(getContext().getAssets(), “robotobold.ttf”);
This worked Typeface typeface = ResourcesCompat.getFont(this, R.font.app_font); Found this in the tutorial link by @Eselfar
On Android 5.0 you can set Roboto Medium with sans-serif-medium. This solution, taken from Google iosched 2014, uses sans-serif on Android pre-v21: values/styles.xml <style name=”MyStyle”> <item name=”android:fontFamily”>@string/font_fontFamily_medium</item> </style> values/fonts.xml <string name=”font_fontFamily_medium”>sans-serif</string> values-v21/fonts.xml <string name=”font_fontFamily_medium”>sans-serif-medium</string>
On Mobiletuts+ there is very good tutorial on Text formatting for Android. Quick Tip: Customize Android Fonts EDIT: Tested it myself now. Here is the solution. You can use a subfolder called fonts but it must go in the assets folder not the res folder. So assets/fonts Also make sure that the font ending I … Read more