ScrollView嵌套RecyclerView時只顯示一行元素

有時候在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> 


 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章