private void animateOut(final BottomNavigationView bottomNavigationView) {
    ViewCompat.animate(bottomNavigationView)
        .translationY(bottomNavigationView.getHeight())
        .setInterpolator(INTERPOLATOR)
        .withLayer()
        .setUpdateListener(
            new ViewPropertyAnimatorUpdateListener() {
              @Override
              public void onAnimationUpdate(final View view) {
                updateSnackBarMargin(view);
              }
            })
        .setListener(
            new ViewPropertyAnimatorListener() {
              public void onAnimationStart(View view) {
                BottomNavigationBehavior.this.mIsAnimatingOut = true;
              }

              public void onAnimationCancel(View view) {
                BottomNavigationBehavior.this.mIsAnimatingOut = false;
              }

              public void onAnimationEnd(View view) {
                BottomNavigationBehavior.this.mIsAnimatingOut = false;
              }
            })
        .start();
  }
 private void resetPreMenuItem() {
   if (mPrevMenuItem != null) {
     mPrevMenuItem.setChecked(false);
   } else {
     mBottomNavigationView.getMenu().getItem(0).setChecked(false);
   }
 }
  public void changeToFour(View v) {
    //        activateNewButton(mBottomNavigationView, 3);

    resetPreMenuItem();
    mPrevMenuItem = mBottomNavigationView.getMenu().getItem(3);
    mPrevMenuItem.setChecked(true);
    mViewPager.setCurrentItem(3);
  }
 public static void activateNewButton(BottomNavigationView bottomNavigationView, int position) {
   BottomNavigationMenuView bottomNavigationMenuView =
       (BottomNavigationMenuView) bottomNavigationView.getChildAt(0);
   try {
     Method activateNewButtonMethod =
         bottomNavigationMenuView.getClass().getDeclaredMethod("activateNewButton", int.class);
     activateNewButtonMethod.setAccessible(true);
     activateNewButtonMethod.invoke(bottomNavigationMenuView, position);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  /**
   * 取消大于三项时占用其他 item 的空间
   *
   * @param bottomNavigationView
   */
  public static void disableShiftMode(BottomNavigationView bottomNavigationView) {
    BottomNavigationMenuView bottomNavigationMenuView =
        (BottomNavigationMenuView) bottomNavigationView.getChildAt(0);
    try {
      Field shiftingModeField =
          bottomNavigationMenuView.getClass().getDeclaredField("mShiftingMode");
      shiftingModeField.setAccessible(true);
      shiftingModeField.setBoolean(bottomNavigationMenuView, false);
      shiftingModeField.setAccessible(false);

      for (int i = 0; i < bottomNavigationMenuView.getChildCount(); i++) {
        BottomNavigationItemView bottomNavigationItemView =
            (BottomNavigationItemView) bottomNavigationMenuView.getChildAt(i);
        bottomNavigationItemView.setShiftingMode(false);
        bottomNavigationItemView.setChecked(bottomNavigationItemView.getItemData().isChecked());
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  private void initBottomNavigationView() {
    mBottomNavigationView.setOnNavigationItemSelectedListener(
        item -> {
          // 结合 ViewPager 使用时
          switch (item.getItemId()) {
            case R.id.action_one:
              mViewPager.setCurrentItem(0);
              break;
            case R.id.action_two:
              mViewPager.setCurrentItem(1);
              break;
            case R.id.action_three:
              mViewPager.setCurrentItem(2);
              break;
            case R.id.action_four:
              mViewPager.setCurrentItem(3);
              break;
          }
          return true;
        });

    disableShiftMode(mBottomNavigationView);
  }