I am hiding the Toolbar
when scrolled down, the only views left would be the SlidingTabLayout
and the ViewPager
, just like the behaviour that PlayStore has. But I can see a white empty space after the SlidingTabLayout
is moved. How do I eliminate this and let the ViewPager
occupies that extra space?
When scrolled up, Toolbar
shows
When scrolled down, it leaves empty space from SlidingTabLayout
@Override
public void onScrollUp() {
if (isToolbarHidden()) showToolbar();
}
@Override
public void onScrollDown() {
if (isToolbarShown()) hideToolbar();
}
private void showToolbar() {
moveToolbar(0);
moveTabs(0);
}
private void hideToolbar() {
moveToolbar(-mToolbar.getHeight());
moveTabs(-mTabs.getHeight());
}
private void moveTabs(float toTranslationY) {
if (ViewHelper.getTranslationY(mTabs) == toTranslationY) return;
ValueAnimator animator = ValueAnimator.ofFloat(ViewHelper
.getTranslationY(mTabs), toTranslationY)
.setDuration(ANIMATE_TIME_MILLIS);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float translationY = (float) animation.getAnimatedValue();
ViewHelper.setTranslationY(mTabs, translationY);
}
});
animator.start();
}