Reputation: 591
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 :-)
Upvotes: 0
Views: 807
Reputation: 5591
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
.
Upvotes: 2