I am trying to add a custom roboto font to my android button; however, most solutions aren't working in this case.
I am trying to use solutions from here...Setting Button text font in android
I have fonts right here in my assets folder.
Here is a snippet of my code:
Button block_block_font =(Button) findViewById(R.id.block_button);
Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Light.ttf");
block_block_font.setText("show");
block_block_font.setTypeface(typeface);
Button security_settings_button_font =(Button) findViewById(R.id.security_settings_button);
security_settings_button_font.setText("show");
security_settings_button_font.setTypeface(typeface);
Button blacklist_whitelist_button_font =(Button) findViewById(R.id.blacklist_whitelist_button);
blacklist_whitelist_button_font.setText("show");
blacklist_whitelist_button_font.setTypeface(typeface);
However, when I apply that solution for editing I produce this error:
06-14 16:59:56.677 26389-26389/com.spicycurryman.getdisciplined10.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.spicycurryman.getdisciplined10.app/com.spicycurryman.getdisciplined10.app.MainActivity}: java.lang.RuntimeException: native typeface cannot be made
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2247)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2297)
at android.app.ActivityThread.access$700(ActivityThread.java:152)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1282)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5328)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: native typeface cannot be made
at android.graphics.Typeface.<init>(Typeface.java:307)
at android.graphics.Typeface.createFromAsset(Typeface.java:281)
at com.spicycurryman.getdisciplined10.app.MainActivity.onCreate(MainActivity.java:39)
at android.app.Activity.performCreate(Activity.java:5250)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2297)
at android.app.ActivityThread.access$700(ActivityThread.java:152)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1282)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5328)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Not sure why a native typeface cannot be made for me when it works for everyone else ...?