51

recyclerview 布局定义为

     <android.support.v7.widget.RecyclerView
            android:layout_marginTop="15dp"
            android:id="@+id/call_detail_list"
            android:scrollbars="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            tools:listitem="@layout/call_item"
            />

在预览中,我可以看到指定布局的列表项,但项数是 10。有什么办法可以改变吗?

4

2 回答 2

118

试试这个(3个项目)

tools:itemCount="3"

于 2017-10-23T22:48:39.230 回答
0

不是最好的方法,但您可以限制layout_height此处,以便它仅显示足够的符合高度/宽度边界的项目。所以玩弄tools:layout_height="150dp"

于 2017-03-10T20:15:43.183 回答