我想更改自定义工具栏的字体。
我的问题是,这不是一个静态的文本视图。我尝试使用这样的Spannable String:
SpannableString s = new SpannableString("My Title");
s.setSpan(new TypefaceSpan(this, "font.otf"), 0, s.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
collapsingToolbarLayout.setTitle(s);
但它不会起作用:-( 在图片中你可以看到它的样子......
http://www.directupload.net/file/d/4066/ye8tcshb_png.htm
http://www.directupload.net/file/d/4066/oh7t6ddv_png.htm
感谢您的回答: - )
答案 0 :(得分:2)
尝试以下代码
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");
当然将font.ttf
文件放在assets/fonts
文件夹中。
请注意,TextView
中的Toolbar
与任何其他TextView
一样。