Flash or flicker occurs during the Fragment switchover. The original method is as follows:

 private void switchPages(int index) {
     if (ListUtils.isEmpty(mFragments)) {
         return;
     }
     FragmentManager fragmentManager = getChildFragmentManager();
     FragmentTransaction transaction = fragmentManager.beginTransaction();
     Fragment fragment;
     for (int i = 0, j = mFragments.size(); i < j; i++) {
         if (i == index) {
             continue;
         }
         fragment = mFragments.get(i);
         if (fragment.isAdded()) {
             transaction.hide(fragment);
             transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
         }
     }
     fragment = mFragments.get(index);
     if (fragment.isAdded()) {
         transaction.show(fragment);
     } else {
         transaction.add(R.id.fl_home_container, fragment);
     }
     transaction.commitAllowingStateLoss();
 }
Copy the code

Lead to the problem of the code is the transaction. SetTransition (FragmentTransaction. TRANSIT_FRAGMENT_FADE) in setting up the animation. If the setTransition animation is unanimated, the display is normal.