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