Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I know this was asked ages ago but I've spent a while trying to sort this out so this is for anybody who has found this question and still wants to know the answer.</p> <p>First make an xml file with this in it: tab_title.xml</p> <pre><code>&lt;TextView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/action_custom_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="My Custom title" android:textColor="#fff" android:textSize="18sp" android:paddingTop="5dp" /&gt; </code></pre> <p>Then in the class where you in instantiate your ActionBar use this code to set the text on each of the tabs. (This example is using <a href="http://actionbarsherlock.com/" rel="noreferrer">ActionBarSherlock</a>.)</p> <pre><code>ActionBar bar = getSupportActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); String[] tabNames = {"Tab 1","Tab 2","Tab 3"}; for(int i = 0; i&lt;bar.getTabCount(); i++){ LayoutInflater inflater = LayoutInflater.from(this); View customView = inflater.inflate(R.layout.tab_title, null); TextView titleTV = (TextView) customView.findViewById(R.id.action_custom_title); titleTV.setText(tabNames[i]); //Here you can also add any other styling you want. bar.getTabAt(i).setCustomView(customView); } </code></pre> <p>Hope this helps anybody who was having trouble like me.</p> <p><strong>//update 1/6/2015</strong></p> <p>if you are using TabLayout in <strong>android M preview</strong> and you want to change the font you have to add a new for loop to the previous solution like this:</p> <pre><code> private void changeTabsFont() { ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0); int tabsCount = vg.getChildCount(); for (int j = 0; j &lt; tabsCount; j++) { ViewGroup vgTab = (ViewGroup) vg.getChildAt(j); int tabChildsCount = vgTab.getChildCount(); for (int i = 0; i &lt; tabChildsCount; i++) { View tabViewChild = vgTab.getChildAt(i); if (tabViewChild instanceof TextView) { ((TextView) tabViewChild).setTypeface(Font.getInstance().getTypeFace(), Typeface.NORMAL); } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload