在最近項目中遇到 ,在RecyclerView加載list數據時,高度沒法自適應增加,看了不少博客,各類嘗試,都沒有解決這個問題,在某個博客中,講到此解決方法,在此記錄下。android
即在RecyclerView 佈局時用 RelativeLayout 包裹着,即:佈局
<RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white" android:orientation="vertical" > <android.support.v7.widget.RecyclerView android:id="@+id/id_rv_orders" android:layout_width="match_parent" android:layout_height="match_parent" /> </RelativeLayout>
就能夠自適應item數量高度spa