title: tabLayout switch delay and views show delay too
body: <p>I put the frame Layout in a Activity and put numbers of Fragment into frame Layout.</p>
  
  <p>The fragment swith by my custom Drawer menu.</p>
  
  <p>One of the Fragments,it has a tabLayout and four tabs to switch. </p>
  
  <p>So my problem is when i switch back to the fragment,the tab shows dealy.</p>
  
  <p>I try to put the code transaction.addToBackStack(null);  It doesn't work.</p>
  
  <p>Please to teach me how to solve this delay,thanks.</p>
  
  <p>here is my code:</p>
  
  <pre><code>@Override
      public boolean onNavigationItemSelected(@NonNull MenuItem item) {
  
          int id = item.getItemId();
      FragmentManager manager = getSupportFragmentManager();
          FragmentTransaction transaction = manager.beginTransaction();
      if (id == R.id.homePage) {
              Homepage homepageFragment = new Homepage();
              transaction.addToBackStack(null);
              transaction.replace(R.id.mainFrame, homepageFragment, null);
              setTitleBar(R.string.appTitle);
              transaction.commit();
  
          } else if (id == R.id.newestInformation) {
              NewsInformation newsFragment = new NewsInformation();
              transaction.addToBackStack(null);
              transaction.replace(R.id.mainFrame, newsFragment, null);
              setTitleBar(R.string.newestInformation);
              transaction.commit();
          }
  </code></pre>
  
  <p>//setContentView</p>
  
  <pre><code>FragmentManager manager = getSupportFragmentManager();
  FragmentTransaction transaction = manager.beginTransaction();
  Homepage homepageFragment = new Homepage();
  Fragment fragment = manager.findFragmentById(R.id.mainFrame);
  if (fragment == null) {
      transaction.addToBackStack(null);
      transaction.add(R.id.mainFrame, homepageFragment, null);
      setTitleBar(R.string.appTitle);
      transaction.commit();
  } else {
      Log.i(TAG, "&gt;&gt;&gt;" + "homepageFragment!=null");
  }
  </code></pre>
  
  <p>//xml</p>
  
  <pre><code>&lt;android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/drawerLayout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;android.support.design.widget.AppBarLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="#FFFFFF"&gt;
  
  
          &lt;android.support.v7.widget.Toolbar
              android:id="@+id/id_toolbar"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              app:theme="@style/ToolBarStyle"
              android:background="@color/colorAccent"&gt;
  
              &lt;TextView
                  android:id="@+id/textTitle"
                  android:textSize="18dp"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:textColor="@android:color/background_light" /&gt;
  
          &lt;/android.support.v7.widget.Toolbar&gt;
  
          &lt;FrameLayout
              android:id="@+id/mainFrame"
              android:layout_width="match_parent"
              android:layout_height="match_parent"&gt;&lt;/FrameLayout&gt;
  
      &lt;/android.support.design.widget.AppBarLayout&gt;
  
  
      &lt;android.support.design.widget.NavigationView
          android:id="@+id/nav_view"
          android:layout_width="240dp"
          android:layout_height="match_parent"
          android:layout_gravity="start"
          android:background="@android:color/white"
          android:fitsSystemWindows="true"
          app:headerLayout="@layout/nav_header"
          app:menu="@menu/drawer_menu" /&gt;
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>//the fragment xml</p>
  
  <pre><code>&lt;android.support.design.widget.AppBarLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@android:color/white"&gt;
  
      &lt;android.support.design.widget.TabLayout
          android:layout_width="match_parent"
          android:id="@+id/tabLayoutHomePage"
          android:layout_weight="1"
          app:tabTextColor="@android:color/white"
          android:background="@color/colorPrimary"
          android:layout_height="80dp"&gt;
  
      &lt;/android.support.design.widget.TabLayout&gt;
  
      &lt;view
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          class="android.support.v4.view.ViewPager"   
          android:id="@+id/viewPager"
          android:layout_weight="1" /&gt;
  
  &lt;/android.support.design.widget.AppBarLayout&gt;
  </code></pre>