protected void hideOrShowToolbar() { mAppBar.animate() .translationY(mIsHidden ? 0 : -mAppBar.getHeight()) .setInterpolator(new DecelerateInterpolator(2)) .start(); mIsHidden = !mIsHidden; } }
protected void hideOrShowToolBar() { appBarLayout.animate() .translationY(isToolBarHiding?0:-appBarLayout.getHeight()) .setInterpolator(new DecelerateInterpolator(2)) .start(); isToolBarHiding = !isToolBarHiding; } }
protected void hideOrShowToolbar() { if (isHide) { //显示 ImmersiveUtil.exit(this); mAppBarLayout.animate() .translationY(0) .setInterpolator(new DecelerateInterpolator(2)) .start(); isHide = false; } else { //隐藏 ImmersiveUtil.enter(this); mAppBarLayout.animate() .translationY(-mAppBarLayout.getHeight()) .setInterpolator(new DecelerateInterpolator(2)) .start(); isHide = true; } }
@Override public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target) { super.onStopNestedScroll(coordinatorLayout, child, target); float translation = child.getTranslationY(); if (translation != 0 && translation != -actionBarHeight) { if ((velocity == 0 && translation > -actionBarHeight / 2) || (velocity != 0 && velocity < -minVelocity)) { int duration = (int) Math.abs(child.getTranslationY()); duration = velocity == 0 ? duration * 2 : duration; child.animate().translationY(0).setDuration(duration).start(); } else { int duration = (int) Math.abs(child.getTranslationY() + actionBarHeight); duration = velocity == 0 ? duration * 2 : duration; child.animate().translationY(-actionBarHeight).setDuration(duration).start(); } } }
protected void hideOrShowToolbar() { if (isHide) { //显示 ImmersiveUtil.exit(this); mAppBarLayout.animate() .translationY(0) .setInterpolator(new DecelerateInterpolator(2)) .start(); isHide = false; } else { //隐藏 ImmersiveUtil.enter(this); mAppBarLayout.animate() .translationY(-mAppBarLayout.getHeight()) .setInterpolator(new DecelerateInterpolator(2)) .start(); isHide = true; } }
protected void hideOrShowToolbar() { if (isHide) { //显示 ImmersiveUtil.exit(this); mAppBarLayout.animate() .translationY(0) .setInterpolator(new DecelerateInterpolator(2)) .start(); isHide = false; } else { //隐藏 ImmersiveUtil.enter(this); mAppBarLayout.animate() .translationY(-mAppBarLayout.getHeight()) .setInterpolator(new DecelerateInterpolator(2)) .start(); isHide = true; } }
protected void hideOrShowToolbar() { if (isHide) { //显示 ImmersiveUtil.exit(this); mAppBarLayout.animate() .translationY(0) .setInterpolator(new DecelerateInterpolator(2)) .start(); isHide = false; } else { //隐藏 ImmersiveUtil.enter(this); mAppBarLayout.animate() .translationY(-mAppBarLayout.getHeight()) .setInterpolator(new DecelerateInterpolator(2)) .start(); isHide = true; } } }
public void hideOrShowToolbar() { getView().getAppBarLaytout().animate() .translationY(mIsHidden ? 0 : -getView().getAppBarLaytout().getHeight()) .setInterpolator(new DecelerateInterpolator(2)) .start(); mIsHidden = !mIsHidden; }