Android Recyclerview不滚动嵌套scrollview中列表的所有元素

Android Recyclerview不滚动嵌套scrollview中列表的所有元素,android,android-layout,android-recyclerview,android-nestedscrollview,Android,Android Layout,Android Recyclerview,Android Nestedscrollview,Recyclerview不会滚动嵌套滚动视图中适配器的所有元素。如果我使用Recyclerview而不使用嵌套的scrollview,它可以正常工作 搜索多个解决方案后,将布局高度设置为扭曲recyclerview和嵌套scrollview的内容 这是我的布局 <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/r

Recyclerview不会滚动嵌套滚动视图中适配器的所有元素。如果我使用Recyclerview而不使用嵌套的scrollview,它可以正常工作

搜索多个解决方案后,将布局高度设置为扭曲recyclerview和嵌套scrollview的内容

这是我的布局

<androidx.coordinatorlayout.widget.CoordinatorLayout               
 xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"                
 android:layout_height="match_parent"
 xmlns:app="http://schemas.android.com/apk/res-auto">

            <com.google.android.material.appbar.AppBarLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:theme="@style/AppTheme.AppBarOverlay"
              tools:ignore="Missing Constraints">
            <androidx.appcompat.widget.Toolbar
              android:id="@+id/transactionHistoryToolbar"
              android:layout_width="match_parent"
              android:layout_height="?attr/actionBarSize"
              android:background="@color/groupColor"
              android:elevation="@dimen/_2"
              android:theme="@style/AppTheme.PopupOverlay">
            </androidx.appcompat.widget.Toolbar>
            </com.google.android.material.appbar.AppBarLayout>

           <androidx.core.widget.NestedScrollView
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:isScrollContainer="true"
             android:measureAllChildren="true"
             app:layout_behavior="@string/appbar_scrolling_view_behavior">

           <androidx.constraintlayout.widget.ConstraintLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginBottom="@dimen/_2">

             <TextView/>
              //other views
                <LinearLayout/>

                 <TextView/>

                    <LinearLayout/>

               <TextView/>

                       <LinearLayout/>

                 <Button
                  />

                  <androidx.recyclerview.widget.RecyclerView
                     android:id="@+id/shipmentList"
                      android:layout_width="match_parent"
                      android:layout_height="0dp"
                     android:layout_marginTop="@dimen/_10"
                     android:layout_marginLeft="@dimen/_7"
                    android:layout_marginRight="@dimen/_7"
                     android:clickable="true"
                     android:visibility="gone"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">             
        </androidx.recyclerview.widget.RecyclerView>
                   <TextView/>
                   </androidx.constraintlayout.widget.ConstraintLayout>          
                  </androidx.core.widget.NestedScrollView>

                  </androidx.coordinatorlayout.widget.CoordinatorLayout>

我找到了解决办法。constraintLayout的主要问题。替换为相对布局后,它可以正常工作。

您也可以设置此行

ViewCompat.setNestedScrollingEnabledrecyclerView,false;
当我们用xml编写时,我遇到了同样的问题,因此我引用了一个与您共享的链接

在您的问题中添加java/kotlin类文件。为什么recyclerview的布局高度为0dp?您是否已禁用此recyclerview.setNestedScrollingEnabledfalse;?recyclerView.setHasFixedSizetrue;recyclerView.setNestedScrollingEnabledfalse;这两行需要添加到您的类文件中。这两行都添加到我的类文件@snehasarkaries i have@sanjeev中