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

AndroidAndroid LayoutAndroid StudioAndroid Tools-Namespace

Android Problem Overview


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?

Android Solutions


Solution 1 - Android

Try this (3 number of items)

tools:itemCount="3"

Solution 2 - Android

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"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionshakdwipeeaView Question on Stackoverflow
Solution 1 - AndroidDiego AlvisView Answer on Stackoverflow
Solution 2 - AndroidRubin YooView Answer on Stackoverflow