2

My CollapsingToolbarLayout doesn't work with RecyclerView if that RecyclerView's ViewHolder contains another horizontal RecyclerView. Anyone can help me?First thank you all. My main Xml is:

<?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:id="@+id/circlebd_rootview"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="256dip"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsingToolbarLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                android:src="@drawable/header"
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.4" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:minHeight="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
    android:id="@+id/circleinfo_recycler"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/recyclerbg"
    android:fillViewport="true"
    android:layout_marginBottom="?attr/actionBarSize"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"/></android.support.design.widget.CoordinatorLayout>

And this is my ViewHodler:

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dip"
android:background="@color/gray_light"
android:paddingBottom="1dp">
<RelativeLayout
    android:id="@id/con_item_r1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/contentitem_top"
    android:paddingBottom="10dip">

</RelativeLayout>
<android.support.v7.widget.RecyclerView
    android:id="@id/con_item_recyclerview"
    android:layout_width="match_parent"
    android:layout_height="@dimen/showimg_height"
    android:layout_below="@id/con_item_r1"/>

The ViewHolder's RecyclerView is horizontal.And main activity's RecyclerView is vertical. If I change ViewHolder's RecyclerView to View,CollapsingToolbarLayout is OK. My question is how can I use ViewHolder's RecyclerView and also let the CollapsingToolbarLayout work.

Andy.Zhao
  • 250
  • 3
  • 16

3 Answers3

2
RecyclerView recyclerView = someView.findViewById(R.id.con_item_recyclerview);

recyclerView.setNestedScrollingEnabled(false);

this will work.

user3531883
  • 253
  • 1
  • 2
  • 6
0

I had a very similar problem to you and this is how I managed to solve it:

Outer Recyclerview not receiving scroll events of inner Recyclerview

Community
  • 1
  • 1
Simon
  • 19,658
  • 27
  • 149
  • 217
0

You can also set in xml layout file by specifying following attribute:

android:nestedScrollingEnabled="false"
Saty
  • 1,068
  • 11
  • 24