Question

I am trying to set a custom font Dosis-Medium.otf which is placed in the asssets folder under a subfolder font. I am trying to use the following code but it gives me an error

The constructor TypefaceSpan(Profile, String) is undefined. Please guide me step by step where I am going wrong.

My code snippet is as follows:

   SpannableString s = new SpannableString("My Title");
   s.setSpan(new TypefaceSpan(this, "Dosis-Medium.otf"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
   ActionBar actionBar = getActionBar();
   actionBar.setTitle(s);
Was it helpful?

Solution

hi as you are getting error The constructor TypefaceSpan(Profile, String) is undefined

please visit for TypefaceSpan doc

https://gist.github.com/twaddington/b91341ea5615698b53b8

as the constructor is defined a s

TypefaceSpan(Context context, String typefaceName)

please pass Context properly of yours activity/app

as i think you are using the code from

http://www.tristanwaddington.com/2013/03/styling-the-android-action-bar-with-a-custom-font/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top