Change font in android -
i know question has been asked many times still not getting right.so please me.i want change font of textviews.i find code on google , end doing this
code
public class sliderfont extends textview { public sliderfont(context context, attributeset attrs) { super(context, attrs); typeface typeface = typeface.createfromasset(context.getassets(), "fonts/redhead.ttf"); settypeface(typeface); } }
and used in xml
<pocketdocs.indiehustlers.com.pocketdocsv2.utils.sliderfont android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginleft="5dp" android:text="awaited approval" android:textcolor="#fff" android:textsize="@dimen/edit_text_size" />
but still not getting desired font.
i have created assets folder
instead :
typeface typeface = typeface.createfromasset(context.getassets(), "fonts/redhead.ttf"); settypeface(typeface);
try use :
typeface typeface = typeface.createfromasset(getresources().getassets(), "fonts/redhead.ttf"); yourtv.settypeface(typeface);
Comments
Post a Comment