title: Lag when switching tabs in BottomNavigationView
body: <p>I have an Activity that contains a BottomNavigationView, and this bottomnav helps the activity to display three fragments. These fragments load well, and I use an AsyncTask to do every heavy operation, while in the UI thread, I show a ProgressBar until everything loads.<br>
  There is a weird behaviour with my fragment: The first time I load the fragment it takes some time to actually display it, instead of displaying it instantly with a progressbar.<br>
  This thing only happens the first time, and only in this fragment.<br>
  The fragment code only contains this:       </p>
  
  <pre><code>@Override
      public void onActivityCreated(@Nullable Bundle savedInstanceState) {
          super.onActivityCreated(savedInstanceState);
          new LoadData(getView(), getContext()).execute();
      }
  
  private class LoadData extends AsyncTask&lt;Void, Void, Void&gt; {
  
          private View v;
          private Context context;
  
          public LoadData(View v, Context context) {
              items = new ArrayList&lt;&gt;();
              this.v = v;
              this.context = context;
          }
  
          @Override
          protected Void doInBackground(Void... voids) {
              setItems(context); //Heavy operation
              adapter = new DashAdapter(items, context);
              return null;
          }
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              //shows progressbar
              progress = v.findViewById(R.id.DFProgress);
              progress.setVisibility(View.VISIBLE);
          }
  
          @Override
          protected void onPostExecute(Void aVoid) {
              super.onPostExecute(aVoid);
              setPager();
              //sets viewPager and hides progressbar
              progress.setVisibility(View.GONE);
          }
      }
  </code></pre>
  
  <p>In the gif below, if you look at the bottomnavigationview at the bottom, you can see that it takes time to display the fragment. But after trying to load the fragment a second time, it loads as expected.
  <a href="https://i.stack.imgur.com/AHbXM.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/AHbXM.gif" alt="enter image description here"></a></p>
  
  <p>How could I make the fragment to load the right way?</p>