如何自定义的操作栏选项卡上的字体 [英] How to customize the font of Action Bar tabs
本文介绍了如何自定义的操作栏选项卡上的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何设置文本字体为动作条的标签,有没有办法来处理每个标签的TextView中?
How to set the text font for the ActionBar tabs, is there a way to deal with the textview of each tab?
推荐答案
首先你需要一个字样
Typeface droidSerifMonoTF = Typeface.createFromAsset(getAssets(), "fonts/DroidSerif.ttf");
remmber该字体位置是在资产目录(在本实施例中它是在/assets/fonts/DroidSerif.ttf)
remmber that the font locations is in the assets directory (in this example it's in /assets/fonts/DroidSerif.ttf)
比,所有的标签,创建一个TextView,将其指定的字体,并给它一个自定义视图的动作条的标签:
than, for all the tabs, create a textview, assign it the typeface and give it as a custom view to the actionbar's tab:
for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
TextView t = new TextView(this);
t.setText(mSectionsPagerAdapter.getPageTitle(i) );
t.setTypeface(droidSansMonoTF);
actionBar.addTab(actionBar.newTab()
.setCustomView(t)
.setTabListener(this));
}
这篇关于如何自定义的操作栏选项卡上的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文