private void setupTab(final Bundle savedInstanceState) {
   tabLayout.post(
       new Runnable() {
         @Override
         public void run() {
           tabLayout.setupWithViewPager(viewPager);
         }
       });
 }
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View x = inflater.inflate(R.layout.home_layout, container, false);
    tabLayout = (TabLayout) x.findViewById(R.id.tabs);
    viewPager = (ViewPager) x.findViewById(R.id.viewpager);

    viewPager.setAdapter(new MyAdapter(getChildFragmentManager()));

    //		setUpWithViewPager doesn't work without using a Runnable interface. Support library bug,
    // maybe?
    tabLayout.post(
        new Runnable() {
          @Override
          public void run() {
            tabLayout.setupWithViewPager(viewPager);
          }
        });
    tabLayout.setElevation(10);
    tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
    return x;
  }