java - Custom Font not working in Fragment Android Studio -
i wanted make custom font textview.
i've got in fragearncredits.java:
public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { super.oncreate(savedinstancestate); if (aiview == null) { aiview = inflater.inflate(r.layout.fragment_earn_credits, container, false); } t = (textview) aiview.findviewbyid(r.id.logo); typeface mycustomfont=typeface.createfromasset(aicontext.getassets(),"fonts/bebas.otf"); t.settypeface(mycustomfont);
in fragment_earn_credits.xml:
<textview android:id="@+id/logo" android:text="fashion wallet" android:gravity="center" android:textsize="40dp" android:textcolor="@color/md_brown_700" android:layout_margintop="100dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparenttop="true" />
and i'm getting null error. why? please me guys!
#edit
i tried change:
typeface mycustomfont=typeface.createfromasset(aicontext.getassets(),"fonts/bebas.otf");
to
typeface mycustomfont = typeface.createfromasset(getactivity().getassets(), "fonts/bebas.otf");
and 0 errors there not changing font.
typeface font = typeface.createfromasset(getactivity().getassets(), "fonts/customfont.ttf");
the context sending in fragment class, have use actual context.
hope helps! cheers!
Comments
Post a Comment