2016-08-11 2 views
0

툴바와 RecyclerView가 포함 된 CoordinatorLayout이 있습니다. 사용자가 RecyclerView를 스크롤 할 때 툴바가 축소되고 숨겨 지도록 레이아웃을 구성했습니다. 이것은 잘 작동합니다. RecyclerView 자체의 셀 (행)에 수평 스크롤 RecyclerView가 포함되어 있지 않은 한. 그런 셀을 탭하고 위로 스크롤하면 툴바가 숨기지 않습니다. CoordinatorLayout은 이러한 셀의 스크롤 이벤트를 처리하고 어떻게 든 혼란스러워합니다. 문제를 해결할 수있는 방법이 있습니까?CoordinatorLayout 스크롤 처리가 중단됩니다.

<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.support.design.widget.AppBarLayout 
     android:id="@+id/main.appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/main.toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:layout_scrollFlags="scroll|enterAlways"> 

      <Button 
       android:id="@+id/button1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Button 1" /> 

      <Button 
       android:id="@+id/button2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Button 2" /> 
     </android.support.v7.widget.Toolbar> 
    </android.support.design.widget.AppBarLayout> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@android:color/white" 
     android:paddingBottom="0pt" 
     android:paddingLeft="0pt" 
     android:paddingRight="0pt" 
     android:paddingTop="0pt" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/recyclerView" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentEnd="true" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentStart="true" 
      android:layout_alignParentTop="true"> 
     </android.support.v7.widget.RecyclerView> 

    </RelativeLayout> 

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

RecycelerView 행 레이아웃을 게시하십시오. – amitairos

답변

0

은 내가이 제기 한 후 SO 순간에 답을 발견

여기 내 레이아웃입니다.

https://stackoverflow.com/a/32975317/1036017

기본적으로 수평 스크롤 RecyclerView가 포함 된 셀에 대해 우리는 중첩 된 스크롤을 사용하지 않도록 설정해야합니다. 이러한 셀의 레이아웃 예는 다음과 같습니다. android:nestedScrollingEnabled 속성을 false로 설정했습니다.

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 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="250dp"> 

    <android.support.v7.widget.RecyclerView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/recyclerView" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentEnd="true" 
     android:nestedScrollingEnabled="false"> 
    </android.support.v7.widget.RecyclerView> 

    <ImageView 
     android:layout_width="30dp" 
     android:layout_height="30dp" 
     android:layout_centerVertical="true" 
     android:layout_alignParentLeft="true" 
     app:srcCompat="@drawable/left_chevron" 
     android:id="@+id/leftArrow" /> 

    <ImageView 
     android:layout_width="30dp" 
     android:layout_height="30dp" 
     android:layout_centerVertical="true" 
     android:layout_alignParentRight="true" 
     app:srcCompat="@drawable/right_chevron" 
     android:id="@+id/rightArrow" /> 
</RelativeLayout> 
관련 문제