Android Typeface createFromAsset -
i have custom view draws text onto canvas. want change font font stored in assets folder.
i using android studio created folder src/main/assets , placed ttf files in there.
paint txt = new paint() typeface font = typeface.createfromasset(getassets(), "robotobold.ttf"); txt.settypeface(font);
problem android studio doesn't recognize getassets() inside custom view, recognizes inside activity. have tried passing typeface through activity when it doesn't change font.
you can use view
's getcontext()
method current context
, use assets:
typeface font = typeface.createfromasset(getcontext().getassets(), "robotobold.ttf");
Comments
Post a Comment