2

My CollapsingToolbarLayout не работает с RecyclerView, если ViewColder RecyclerView содержит еще один горизонтальный RecyclerView. Кто-нибудь может мне помочь? Сначала спасибо всем. Мой главный Xml является:Горизонтальный RecyclerView внутри RecyclerView, что внутри CoordinatorLayout

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

И это мой 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"/> 

RecyclerView В ViewHolder является RecyclerView horizontal.And основным видом деятельности является вертикальной. Если я изменил ViewGolder's RecyclerView на View, CollapsingToolbarLayout в порядке. Мой вопрос в том, как я могу использовать ViewGolder RecyclerView, а также работать CollapsingToolbarLayout.

ответ

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

recyclerView.setNestedScrollingEnabled(false); 

это будет работать.

Смежные вопросы