android - Using custom fonts crashes my application -
i using custom font in application using typeface class. when run application crashes , open .otf file in tab. images linked. thanx in advance :-)
here java code:
textview text = new textview(this); layoutparams params = new layoutparams(layoutparams.wrap_content, layoutparams.wrap_content); //params.setmargins(100,100,500,100); typeface tf = typeface.createfromasset(getassets(),"/fonts/adobearabic-regular.otf"); text.settypeface(tf); text.setpadding(150,100,150,100); text.setgravity(gravity.center_horizontal); text.settextcolor(getresources().getcolor(r.color.white)); //text.setbackgroundresource(r.color.green); text.setlayoutparams(params);
please try below one.
typeface tf = typeface.createfromasset(getassets(), "fonts/adobearabic-regular.otf");
you added '/'
in front of fonts.
Comments
Post a Comment