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 –