ScrollView嵌套RecyclerView时只显示一行元素

2018-08-22  本文已影响498人  df661d1e16ba

有时候在ScrollView中嵌套RecyclerView会发现RecyclerView只显示一行元素,这可能是Android的一个bug,解决方法是在RecyclerView外层套一层RelativeLayout。并设置android:nestedScrollingEnabled="false"

<RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <android.support.v7.widget.RecyclerView
                    android:id="@+id/rv_news2"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/colorWhite"
                    android:nestedScrollingEnabled="false" />
</RelativeLayout> 
上一篇 下一篇

猜你喜欢

热点阅读