title: Android Design Support Library and TabLayout
body: <p>I've got a bit of a interesting problem (if that's the right word!) I recently updated to the latest Android Design Support Library 'com.android.support:design:22.2.1' updated from 'com.android.support:design:22.2.0'</p>
  
  <p>After the update I noticed a strange thing happening with the Tab text and tab scroll bar not showing when I ran the app (tried on different phones and different versions of Android - 4.4.4 &amp; 5.1.1) when using the new TabLayout from the support library.</p>
  
  <p>Interestingly after I rotated the screen the tab text and scroll bar appeared, and remained - I'm not sure if this is issue with my code (posted below) or a bug in the library.  When I go back to 'com.android.support:design:22.2.0' this problem disappears, but I'm not ruling out either.  Just wanted to see if others may have experienced this problem with the new design support library.</p>
  
  <p><strong>My Code:</strong></p>
  
  <p><strong>Fragment Layout with TabLayout:</strong></p>
  
  <pre><code>LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      tools:context="com.treefrogapps.TaDo.TaDOChooserFragment"&gt;
  
      &lt;android.support.design.widget.TabLayout
          android:id="@+id/chooserFragmentSlidingTabsLayout"
          android:layout_width="match_parent"
          android:layout_height="56dp"
          app:tabMode="fixed"/&gt;
  
      &lt;android.support.v4.view.ViewPager
          android:id="@+id/chooserFragmentViewPager"
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="1"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>Fragment Java Class</strong></p>
  
  <pre><code>public class TaDOChooserFragment extends Fragment {
  
      private View rootView;
      private ViewPager mViewPager;
      private TabLayout mTabLayout;
  
      public TaDOChooserFragment() {
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
  
          rootView = inflater.inflate(R.layout.fragment_tado_chooser, container, false);
          return rootView;
      }
  
      @Override
      public void onActivityCreated(Bundle savedInstanceState) {
          super.onActivityCreated(savedInstanceState);
  
          initialiseTabs();
      }
  
      private void initialiseTabs() {
  
          mViewPager = (ViewPager) rootView.findViewById(R.id.chooserFragmentViewPager);
          mViewPager.setAdapter(new TaDOChooserPagerAdapter(getActivity(), getChildFragmentManager()));
          // new design library tab layout
          mTabLayout = (TabLayout) rootView.findViewById(R.id.chooserFragmentSlidingTabsLayout);
          mTabLayout.setBackgroundColor(getResources().getColor(R.color.primaryColor));
          mTabLayout.setTabTextColors(getResources().getColor(R.color.grey_light), getResources().getColor(R.color.white));
          mTabLayout.setupWithViewPager(mViewPager);
  
          mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
              @Override
              public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
              }
  
              @Override
              public void onPageSelected(int position) {
  
                  Fragment fragment = ((TaDOChooserPagerAdapter) mViewPager.getAdapter()).getFragment(position);
                  if (fragment !=null){
                      fragment.onResume();
                  }
              }
  
              @Override
              public void onPageScrollStateChanged(int state) {
  
              }
          });
      }
  }
  </code></pre>
  
  <p><strong>Fragment Pager Adapter :</strong></p>
  
  <pre><code>public class TaDOChooserPagerAdapter extends FragmentPagerAdapter {
  
      private String[] tabTitlesArray;
      private Context context;
      private FragmentManager fragmentManager;
      private HashMap&lt;Integer, String&gt; fragmentTags;
  
  
      public TaDOChooserPagerAdapter(Context context, FragmentManager fm) {
          super(fm);
  
          tabTitlesArray = context.getResources().getStringArray(R.array.chooser_fragment_tab_title_array);
  
          this.context = context;
          this.fragmentManager = fm;
          this.fragmentTags = new HashMap&lt;&gt;();
      }
  
      @Override
      public Fragment getItem(int position) {
  
          switch (position){
              case 0: return new TaDOChooserTabFragment1();
              case 1: return new TaDOChooserTabFragment2();
              default: return null;
          }
      }
  
      @Override
      public CharSequence getPageTitle(int position) {
          return tabTitlesArray[position];
      }
  
      @Override
      public int getCount() {
          return tabTitlesArray.length;
      }
  
      // used for refreshing tabs after they have been loaded - uses onResume method
      @Override
      public Object instantiateItem(ViewGroup container, int position) {
          Object object = super.instantiateItem(container, position);
  
          if (object instanceof Fragment){
              //record the fragment tag
              Fragment fragment = (Fragment) object;
              fragmentTags.put(position, fragment.getTag());
          }
  
          return object;
      }
  
      public Fragment getFragment(int position){
  
          if(fragmentTags.get(position) == null) return null;
          return fragmentManager.findFragmentByTag(fragmentTags.get(position));
      }
  }
  </code></pre>