1

これは、折りたたみ可能なツールバー アニメーションを作成するために使用している xml です。

主なレイアウト:

   <android.support.design.widget.CoordinatorLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        <android.support.design.widget.AppBarLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:fitsSystemWindows="true">
                <include layout="@layout/toolbar"/>
        </android.support.design.widget.AppBarLayout>
            <FrameLayout
            android:id="@+id/container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    </android.support.design.widget.CoordinatorLayout>

ツールバーのレイアウト:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    style="@style/AppTheme.toolbarStyle"
    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="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    app:layout_scrollFlags="scroll|enterAlways"/>

containerFrameLayoutを置き換えるレイアウト:

<android.support.v7.widget.RecyclerView
    android:id="@+id/recycler_list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="none"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

私が得る結果:

ここに画像の説明を入力

明らかな問題は、Recyclerview がツールバーの下に描画され、ツールバーが完全に非表示になってからリストのスクロールが開始されることです。意図したアニメーションは、ツールバーが非表示になると同時にリサイクラー ビューをスクロールすることでした。私が読んだことから、CoordinatorLayout が FrameLayout のサブクラスであるためである可能性があります。どうすれば修正できますか?

4

1 に答える 1