Actionbar title font not changing in android -


i want change custom font action bar title, have gone through couple of accepted answers,but no luck,i have tried below,but custom font not applied actionbar title,please me rid of this,my code below:

java

typeface font = typeface.createfromasset(getactivity().getassets(),                 "neuropolx.ttf");         spannablestring s = new spannablestring(                 "                     kolay randevu");         s.setspan(new customtypefacespan("", font), 0, 4,                 spanned.span_exclusive_inclusive);         getactivity().getactionbar().settitle(s); 

changing actionbar title font not supported, can use custom view action bar. use custom view , disable native title. display between icon , action items. can inherit activities single activity, has code in oncreate:

this.getactionbar().setdisplayshowcustomenabled(true); this.getactionbar().setdisplayshowtitleenabled(false);  layoutinflater inflator = layoutinflater.from(this); view v = inflator.inflate(r.layout.customtitleview, null);  //you can customise text here. //using custom textview custom font in layout xml need set title ((textview)v.findviewbyid(r.id.title)).settext(this.gettitle());  //assign view actionbar this.getactionbar().setcustomview(v); 

and layout xml (r.layout.customtitleview in code above) looks this:

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="@android:color/transparent" >  <com.your.package.customtextview         android:id="@+id/title"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_centervertical="true"             android:layout_marginleft="10dp"             android:textsize="20dp"             android:maxlines="1"             android:ellipsize="end"             android:text="" /> </linearlayout> 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -