2017-06-02 319 views
0

我有BottomSheetBehavior 我使用ConstraintLayout布局,内部布局我有两个RecyclerView 前有两个人RecyclerView的滚动运行完美, 一旦我添加含有相当小的内容,第二RecyclerView, 最多3行,第二个RecyclerView的滚动被禁用,当我将第一个RecyclerView更改为简单的LinearLayout时,它也可以工作。 注:第一个Recyclerview内容相当小,不需要滚动,只有第二个。为什么使用BottomSheetBehavior滚动两个RecyclerView内部布局不起作用?

<android.support.constraint.ConstraintLayout 
     android:id="@+id/store_bottom_sheet" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginBottom="@dimen/bottom_navigation_height" 
     android:background="@android:color/transparent" 
     android:fitsSystemWindows="true" 
     app:behavior_hideable="false" 
     app:behavior_peekHeight="350dp" 
     app:layout_behavior="@string/bottom_sheet_behavior"> 


     <android.support.constraint.ConstraintLayout 
      android:id="@+id/constraintLayout" 
      android:layout_width="0dp" 
      android:layout_height="60dp" 
      android:layout_marginTop="8dp" 
      android:background="@drawable/rounded_shape" 
      app:layout_constraintHorizontal_bias="0.0" 
      app:layout_constraintLeft_toLeftOf="parent" 
      app:layout_constraintRight_toRightOf="parent" 
      app:layout_constraintTop_toTopOf="parent"> 

<ImageView 
       android:id="@+id/imageView" 
       android:layout_width="19dp" 
       android:layout_height="23dp" 
       android:layout_marginStart="16dp" 
       android:layout_marginTop="19dp" 
       app:layout_constraintLeft_toLeftOf="parent" 
       app:layout_constraintTop_toTopOf="parent" 
       app:srcCompat="@drawable/ic_search"/> 
</android.support.constraint.ConstraintLayout> 

    <android.support.v7.widget.RecyclerView 
       android:id="@+id/list_filter" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       app:adapter="@{viewModel.filterAdapter}" 
        app:layout_constraintLeft_toLeftOf="parent" 
      app:layout_constraintRight_toRightOf="parent" 
      app:layout_constraintTop_toBottomOf="@+id/constraintLayout"/> 


<android.support.v7.widget.RecyclerView 
      android:id="@+id/recyclerView2" 
      android:layout_width="0dp" 
      android:layout_height="0dp" 
      android:layout_marginTop="8dp" 
      android:nestedScrollingEnabled="true" 
      app:adapter="@{viewModel.findStoresAdapter}" 
      app:dividerDrawable="@{@drawable/vertical_divider}" 
     app:layoutManager="android.support.v7.widget.LinearLayoutManager" 
      app:layout_constraintBottom_toBottomOf="parent" 
      app:layout_constraintHorizontal_bias="0.0" 
      app:layout_constraintLeft_toLeftOf="parent" 
      app:layout_constraintRight_toRightOf="parent" 
      app:layout_constraintTop_toBottomOf="@+id/list_filter" 
      app:layout_constraintVertical_bias="0.0"/> 
</android.support.constraint.ConstraintLayout> 
+0

你可以在CoordinatorLayout中使用,勾选这个[link](https://stackoverflow.com/a/46681326/4797289) –

回答

0

因为两个RecyclerView在相同方向上滚动相互冲突。使用一个具有不同ViewType的RecyclerView。

相关问题