Assets folder in Android Studio? -
im trying use custom font, , i've read suppose place fonts in assets/fonts. i'm using android studio , doesn't seem have assets folder. created one. app crashes when place assets folder in src/main. im using code load fonts.
typeface fontregular = typeface.createfromasset(getassets(), "fonts/droidsans.ttf"); typeface fontbold = typeface.createfromasset(getassets(), "fonts/droidsans-bold.ttf"); mydevicemodeltxt.settypeface(fontregular); what doing wrong?
i not sure if there has been bug fixes since asked, using current structure project in android studio 0.5.2:
root-module |--.idea |--app |----build |----src |------main |--------assets |----------somefont.ttc |----------anotherfont.otf |--------java |----------source code here |--------res |------androidmanifest.xml |----build.gradle and obtain calling
typeface.createfromasset(mcontext.getresources().getassets(), "somefont.ttc"); word of caution though, there bug (https://code.google.com/p/android/issues/detail?id=9904) prevents typefaces being garbage collected properly. use singleton!
Comments
Post a Comment