Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First create following custom <code>TypefaceSpan</code> class in your project.Bit changed version of <a href="https://gist.github.com/twaddington/b91341ea5615698b53b8" rel="nofollow">Custom TypefaceSpan</a> to enable to use both <code>.otf</code> and <code>.ttf</code> fonts.</p> <pre><code>import java.util.StringTokenizer; import android.content.Context; import android.graphics.Typeface; import android.support.v4.util.LruCache; import android.text.TextPaint; import android.text.style.MetricAffectingSpan; public class TypefaceSpan extends MetricAffectingSpan{ /*Cache to save loaded fonts*/ private static LruCache&lt;String, Typeface&gt; typeFaceCache= new LruCache&lt;String, Typeface&gt;(12); private Typeface mTypeface; public TypefaceSpan(Context context,String typeFaceName) { StringTokenizer tokens=new StringTokenizer(typeFaceName,"."); String fontName=tokens.nextToken(); mTypeface=typeFaceCache.get(fontName); if(mTypeface==null) { mTypeface=Constants.getFont(context, typeFaceName); //cache the loaded font typeFaceCache.put(fontName, mTypeface); } } @Override public void updateMeasureState(TextPaint p) { p.setTypeface(mTypeface); } @Override public void updateDrawState(TextPaint tp) { tp.setTypeface(mTypeface); } } </code></pre> <p>Now apply code like this:(I used this on one of my Bangla apps successfully)</p> <pre><code> SpannableString mstKnwTitle=new SpannableString(getString(R.string.e_mustknow_tab)); SpannableString cntctsTitle=new SpannableString(getString(R.string.e_number_tab)); TypefaceSpan span=new TypefaceSpan(this, "solaimanlipi.ttf"); mstKnwTitle.setSpan(span, 0, mstKnwTitle.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); cntctsTitle.setSpan(span, 0, mstKnwTitle.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); Tab tab= actionBar.newTab(); tab.setText(mstKnwTitle); tab.setTabListener(tabListener); actionBar.addTab(tab); tab= actionBar.newTab(); tab.setText(cntctsTitle); tab.setTabListener(tabListener); actionBar.addTab(tab); </code></pre> <p>Original inspiration of my answer was:<a href="http://www.tristanwaddington.com/2013/03/styling-the-android-action-bar-with-a-custom-font/" rel="nofollow">Styling the Android Action Bar title using a custom typeface</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload