How to specify list item count in preview of recyclerview in Android Studio?
Asked Answered
C

2

54

The recyclerview layout is defined as

     <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"
            />

In the preview, I can see the list items from the specified layout, but the number of item is 10. Is there any way that can be changed?

Circumambulate answered 21/1, 2017 at 6:12 Comment(2)
I have been looking into this as well without success. There's nothing specified in the documentation. developer.android.com/studio/write/…Salahi
You should accept the answer from @Diego Alejandro about setting tools:itemCount="3".Brno
M
123

Try this (3 number of items)

tools:itemCount="3"

Mares answered 23/10, 2017 at 22:48 Comment(2)
This worked for me on Android 3.0 but NOT on Android 2.3.Crosscurrent
This is correct, however it won't work if you also have the tools:listitem property definedPontefract
P
0

Not the best way to do it but you can limit the layout_height here so that it only shows enough items that fits within the height/width boundary. So play around with tools:layout_height="150dp"

Pendent answered 10/3, 2017 at 20:15 Comment(1)
I tried this, but it seems that the tools:listitem argument overrides the layout height... For me the 10 list items still show up.Pavid

© 2022 - 2024 — McMap. All rights reserved.