フラグメント内にRecyclerViewを持つSwipeRefreshLayoutを使用しています。フラグメント内のSwipeRefreshLayoutでRecyclerViewのスクロールが機能しない
RecyclerViewは下にスクロールしません。これは私の主な活動のレイアウトである
:これは正常に動作します
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<include
layout="@layout/toolbar" />
<!-- Replaced with Fragment -->
<LinearLayout
android:id="@+id/fragment_placeholder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/main_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:layout_gravity="start"
android:background="@color/white"
android:scrollbars="vertical"
/>
</android.support.v4.widget.DrawerLayout>
- 断片問題RecyclerViewとは、あなたが上記を参照できるIDのfragment_placeholderでのLinearLayoutを置き換えます。
フラグメントレイアウトはここにある:
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/swipe_refresh_layout">
<android.support.v7.widget.RecyclerView
android:id="@+id/content_recycler_view"
android:layout_width="match_parent
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
スワイプリフレッシュ-ジェスチャーが正常に動作しているが、RecyclerViewの内容は、画面サイズを超えた場合、スクロールが動作しません。
nestedScrollingEnabled(true)を設定しようとしましたが、どちらも機能しません。
RecyclerView dataView = (RecyclerView) layout.findViewById(R.id.content_recycler_view);
final RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
dataView.setLayoutManager(mLayoutManager);
adapter = new ListContentAdapter();
dataView.setAdapter(adapter);
dataView.setNestedScrollingEnabled(true);
私はRecyclerView周りNestedScrollViewを包む場合にのみ、スクロールです:
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/swipe_refresh_layout">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/content_recycler_view"
android:layout_width="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_height="match_parent" />
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
しかし、これはそれの見解を再利用し、RecyclerViewの利点を破壊します。 なぜスクロールしないのですか?
ありがとうございました!
はいNestedscrollviewを追加した後、それはme.Thankあなたのために働いています! –