1

to make a scrolling animation background is not filled, what am I doing wrong?

I am using - DrawerLayout - V7 toolbar - Pager - SwipeRefreshLayout - RecyclerView

Activity

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar" />

    <FrameLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"></FrameLayout>

Fragment pager container

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<com.squidit.squid.ui.widget.SlidingTabLayout
    android:id="@+id/tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:elevation="2dp"
    android:background="@color/primaryColor"/>

<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

Fragment content

<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/missionSwipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<android.support.v7.widget.RecyclerView
    android:id="@+id/recyclerView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"        
    />

Scroll hide

private void hideViews() {
    mToolbar.animate().translationY(-mToolbar.getHeight()).setInterpolator(new DecelerateInterpolator(2));
    container.animate().translationY(-mToolbar.getHeight()).setInterpolator(new DecelerateInterpolator(2)).start();        
}

Problem:

container rises to the top, but the space occupied by it previously on the bottom is without filling

Ilustration:

https://drive.google.com/open?id=0B-Vxv0Qpz2dqcWp5eDVRbmd3czQ&authuser=0

1 Answers1

-1

I had almost the same problem. After hiding toolbar and status bar my layout looks like http://i62.tinypic.com/qowvgi.png.

EDIT: You may noticed that translation is not the same as moving view out. To resize your layout with animation set LayoutParams.height on desired inside ValueAnimator.

mToolbar = (Toolbar) getActivity().findViewById(R.id.toolbar);
    toolbarHeight = mToolbar.getHeight();

and finally

ValueAnimator anim = ValueAnimator.ofInt(toolbarHeight, 0);
    anim.setDuration(1000);
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            Integer value = (Integer) animation.getAnimatedValue();
            mToolbar.getLayoutParams().height = value.intValue();
            mToolbar.requestLayout();

        }
    });
    anim.start();

The code above hides toolbar affecting main layout to expand itself. Idea given from THAT QUESTION.

Also make sure that you are using fitsSystemWindows in layout which is about to be resize.

android:fitsSystemWindows = "true"
Community
  • 1
  • 1
murt
  • 2,982
  • 1
  • 29
  • 44