0
我想在我的应用程序中使用TabLayout
和ViewPager
,但我想为TabLayout
设置自定义字体,但我不能这样做!
我用这个代码:如何在Android中为TabLayout设置自定义字体?
Typeface droidSerifMonoTF = Typeface.createFromAsset(getAssets(), "fonts/DroidSerif.ttf");
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));
}
从这个链接:Link但不工作我!
我该怎么办?
任何错误即将到来或字体不适用? –
您可以使用setCustomView()并在布局xml中为TextView定义字体,请参见:http://stackoverflow.com/questions/31698756/remove-line-break-in-tablayout –
@DanielNugent,tnx我亲爱的朋友<3 –