0

I want to change the font of my custom toolbar.

My problem is that this isn't a static textview. I tried to use a Spannable String like this:

    SpannableString s = new SpannableString("My Title");
    s.setSpan(new TypefaceSpan(this, "font.otf"), 0, s.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);


    collapsingToolbarLayout.setTitle(s);

But it won't works :-( In the pics you can see how it looks like...

http://www.directupload.net/file/d/4066/ye8tcshb_png.htm

http://www.directupload.net/file/d/4066/oh7t6ddv_png.htm

Thanks for answering :-)

FabASP
  • 581
  • 1
  • 6
  • 20

1 Answers1

2

Try the below code

TextView newfont;
newfont=(TextView) findViewById(R.id.textView1);
Typeface font=Typeface.createFromAsset(getAssets(), "fonts/font.ttf");
newfont.setTypeface(font);
newfont.setText("This is the new font Text");

Of course put the font.ttf file inside assets/fonts folder.

Note that TextView inside Toolbar is just like any other TextView.

Read more from here

Sash_KP
  • 5,551
  • 2
  • 25
  • 34
  • Ok yes, this works but that was what I have tried before, yet :-D ehm the problem is that the textview isn't dynamically. In other words, if i scroll down the text appears but if I scroll up the text disappears. It should work like: The text like picture one and if I scroll up in the listview, the text appears in the ActionBar... EDIT: Ok i think I solved this in the xml to put layout_gravity to "bottom". :-) – FabASP Aug 01 '15 at 12:10