Set Android Custom Font on Tab Title
<p>I am trying to set a custom font to the titles ("Tab Item 1", "Tab Item 2",  "Tab Item 3") from the code below. I am really new to Android Studio and Java and am just learning by doing and kind materials that has been over the internet. </p>

<p>Assuming I have a font named "abc.ttf" already in my assets folder, how do I cahange the font for tab title? Below are my TabFragment.java</p>



<pre><code>import android.graphics.Typeface;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.AppCompatTextView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


public class TabFragment extends Fragment {

    TabLayout mTabLayout;
    ViewPager mViewPager;
    private static final int int_items = 3;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        /**
         *Inflate tab_layout and setup Views.
         */
        View x = inflater.inflate(R.layout.tabbed_layout, null);
        mTabLayout = (TabLayout) x.findViewById(R.id.tabs);
        mViewPager = (ViewPager) x.findViewById(R.id.viewpager);

        /**
         *Set an Apater for the View Pager
         */
        mViewPager.setAdapter(new MyAdapter(getChildFragmentManager()));

        /**
         * Now , this is a workaround ,
         * The setupWithViewPager dose't works without the runnable .
         * Maybe a Support Library Bug .
         */

        mTabLayout.post(new Runnable() {
            @Override
            public void run() {
                mTabLayout.setupWithViewPager(mViewPager);
            }
        });

        return x;

    }

    class MyAdapter extends FragmentPagerAdapter {

        public MyAdapter(FragmentManager fm) {
            super(fm);
        }

        /**
         * Return fragment with respect to Position .
         */

        @Override
        public Fragment getItem(int position) {
            switch (position) {
                case 0:
                    return new TabOneFragment();
                case 1:
                    return new TabTwoFragment();
                case 2:
                    return new TabThreeFragment();
            }
            return null;
        }

        @Override
        public int getCount() {

            return int_items;

        }

        /**
         * This method returns the title of the tab according to the position.
         */



        @Override
        public CharSequence getPageTitle(int position) {

            switch (position) {
                case 0:

                    return "Tab Item 1";
                case 1:
                    return "Tab Item 2";
                case 2:
                    return "Tab Item 3";
            }
            return null;
        }
    }

}
</code></pre>



<p>and here is my tabbed_layout.xml</p>



<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout     xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content"&gt;


&lt;android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    app:tabGravity="fill"
    app:tabMode="fixed"
    android:background="@color/white"
    app:tabIndicatorColor="@color/colorPrimary"
    app:tabSelectedTextColor="@color/colorPrimary"
    app:tabTextColor="@color/black"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" /&gt;

&lt;android.support.v4.view.ViewPager
    android:id="@+id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"&gt;

&lt;/android.support.v4.view.ViewPager&gt;


&lt;/LinearLayout&gt;
</code></pre>