private void showToolbar() { float headerTranslationY = ViewHelper.getTranslationY(mHeaderView); if (headerTranslationY != 0) { ViewPropertyAnimator.animate(mHeaderView).cancel(); ViewPropertyAnimator.animate(mHeaderView).translationY(0).setDuration(200).start(); } propagateToolbarState(true); }
@Override public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) { if (dragging) { int toolbarHeight = mHeaderView.getHeight() - mActionBarSize - mStatusSize - tabLayout.getHeight(); float currentHeaderTranslationY = ViewHelper.getTranslationY(mHeaderView); if (firstScroll) { if (-toolbarHeight < currentHeaderTranslationY) { mBaseTranslationY = scrollY; } } float headerTranslationY = ScrollUtils.getFloat(-(scrollY - mBaseTranslationY), -toolbarHeight, 0); ViewPropertyAnimator.animate(mHeaderView).cancel(); ViewHelper.setTranslationY(mHeaderView, headerTranslationY); } toolbar_bac.setImageResource(R.drawable.toolbar_background_black); float a = (float) scrollY / (ViewHelper.getScrollY(mHeaderView)); toolbar_bac.setAlpha(a); }
@Override public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) { if (dragging) { int toolbarHeight = mToolbarView.getHeight(); float currentHeaderTranslationY = ViewHelper.getTranslationY(mHeaderView); if (firstScroll) { if (-toolbarHeight < currentHeaderTranslationY) { mBaseTranslationY = scrollY; } } float headerTranslationY = ScrollUtils.getFloat(-(scrollY - mBaseTranslationY), -toolbarHeight, 0); ViewPropertyAnimator.animate(mHeaderView).cancel(); ViewHelper.setTranslationY(mHeaderView, headerTranslationY); } }
private void hideToolbar() { float headerTranslationY = ViewHelper.getTranslationY(mHeaderView); int toolbarHeight = mHeaderView.getHeight() - mActionBarSize - mStatusSize - tabLayout.getHeight(); if (headerTranslationY != -toolbarHeight) { ViewPropertyAnimator.animate(mHeaderView).cancel(); ViewPropertyAnimator.animate(mHeaderView).translationY(-toolbarHeight).setDuration(200).start(); } propagateToolbarState(false); }
private void hideToolbar() { float headerTranslationY = ViewHelper.getTranslationY(mHeaderView); int toolbarHeight = mToolbarView.getHeight(); if (headerTranslationY != -toolbarHeight) { ViewPropertyAnimator.animate(mHeaderView).cancel(); ViewPropertyAnimator.animate(mHeaderView).translationY(-toolbarHeight).setDuration(200).start(); } propagateToolbarState(false); }
private void showToolbar() { float headerTranslationY = ViewHelper.getTranslationY(mHeaderView); if (headerTranslationY != 0) { ViewPropertyAnimator.animate(mHeaderView).cancel(); ViewPropertyAnimator.animate(mHeaderView).translationY(0).setDuration(200).start(); } propagateToolbarState(true); }