Android скрыть / показать панель инструментов не заполняет пространство внизу

чтобы фон анимации прокрутки не заливался, что я делаю не так?

Я использую - DrawerLayout - панель инструментов V7 - Pager - SwipeRefreshLayout - RecyclerView

Мероприятия

<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>

Контейнер пейджера фрагментов

<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();        
}

Проблема:

контейнер поднимается наверх, но пространство, занимаемое им ранее на дне, остается незаполненным

Иллюстрация:

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


person Mauricio Coelho    schedule 15.04.2015    source источник
comment
Ваша иллюстрация не работает, требуется разрешение. Почему вы перемещаете весь контейнер вместе с панелью инструментов?   -  person Michał Z.    schedule 15.04.2015
comment
@MichałZ. Пожалуйста, проверьте ссылку еще раз. Я обнаружил, что моя проблема связана с drawerlayout, но еще не решил.   -  person Mauricio Coelho    schedule 15.04.2015


Ответы (1)


У меня была почти такая же проблема. После скрытия панели инструментов и строки состояния мой макет выглядит так: http://i62.tinypic.com/qowvgi.png< /а>.

РЕДАКТИРОВАНИЕ. Вы могли заметить, что перевод — это не то же самое, что перемещение представления. Чтобы изменить размер вашего макета с анимацией, установите LayoutParams.height на желаемое значение внутри ValueAnimator.

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

и наконец

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();

Приведенный выше код скрывает панель инструментов, влияющую на основной макет, чтобы расширить себя. Идея взята из ЭТОГО ВОПРОСА.

Также убедитесь, что вы используете fitsSystemWindows в макете, размер которого будет изменен.

android:fitsSystemWindows = "true"
person murt    schedule 11.05.2015
comment
Пожалуйста, не используйте ответы для публикации комментариев. - person elixenide; 12.05.2015
comment
@murt - правильный способ - либо получить больше репутации (и не путать воды чужими вопросами), либо задать свой вопрос. - person David van Driessche; 12.05.2015
comment
любое решение, как удалить черное пространство внизу? - person Ram; 02.08.2016