Skip to content
Ivan Kocijan edited this page Oct 13, 2015 · 1 revision

Font can be added to TabLayout only from code and only after Tabs have been added to TabLayout.

  1. Instead of TabLayout from design library use the one from MagicViews
<com.ivankocijan.magicviews.views.MagicTabLayout
    android:id="@+id/tab_layout"
    android:layout_width="match_parent"
    android:layout_height="100dp"/>
  1. Add tabs to TabLayout and set the font
  
MagicTabLayout tabLayout = (MagicTabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText("Tab 1"));
tabLayout.addTab(tabLayout.newTab().setText("Tab 2"));

tabLayout.setFont("yourfont.ttf");
    

Clone this wiki locally