1

これを実装する方法がわかりません..使用したい:

  1. 折りたたみツールバー
  2. 「通常の」レイアウト (NestedScrollView)
  3. RecyclerView
  4. NavigationDrawerでナビゲートします (したがって、レイアウトは私の activity_main.xml にまとめられます)。

RecyclerView を使用しようとすると問題が発生します - NestedScrollView が原因です (そうです、「複数のスクロール可能オブジェクトを一緒に配置しないでください」というルールは true です)...

しかし、これを達成する方法は?何らかの方法でレイアウトを分離しておく可能性はありますか?

情報: FrameLayout でアプリのコンテンツを置き換えています (中央のセクションを参照)。

複数の NestedScrollViews を挿入するのは適切な解決策でしょうか (スクロール可能にする必要がある各 Fragment ビューに)?

これが私の主なレイアウトです:

<?xml version="1.0" encoding="utf-8"?>

<android.support.design.widget.CoordinatorLayout
    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:fitsSystemWindows="false"
    android:background="@color/main_frame"
    >

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="192dp"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        >

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="@color/colorPrimary"
            app:expandedTitleMarginBottom="32dp"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            >

            <ImageView
                android:id="@+id/header"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/colorPrimary"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                app:layout_collapseMode="parallax"
                />

            <include
                android:id="@+id/toolbar"
                layout="@layout/toolbar_overlay"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                />

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/nestedScrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        >

        <FrameLayout
            android:id="@+id/main_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/toolbar"
            >
        </FrameLayout>

    </android.support.v4.widget.NestedScrollView>

</android.support.design.widget.CoordinatorLayout>

<android.support.design.widget.NavigationView
    android:id="@+id/navigation_view"
    android:layout_height="match_parent"
    android:layout_width="wrap_content"
    android:layout_gravity="start"
    android:background="@color/colorPrimaryNavDrawer"
    app:headerLayout="@layout/nav_drawer_header"
    app:menu="@menu/nav_drawer_items"
    />

前もって感謝します。

4

1 に答える 1

2

RecyclerViewこれを実現する最善の方法は、異なるビュー タイプを処理するアダプタでのみを使用することです。最初のアダプターの位置では、リスト アイテムは で固定コンテンツにNestedScrollViewなり、他の位置ではRecyclerView現在のソリューションのアイテムを使用します。

于 2015-12-28T10:19:05.673 に答える