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); 

here error window:

please try below one.

typeface tf = typeface.createfromasset(getassets(), "fonts/adobearabic-regular.otf"); 

you added '/' in front of fonts.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -