How to use androidx.recyclerview.widget.RecyclerView
with tools:listitem
?
I have this layout:
From your code it seems that your recyclerview is the root element of the XML, and is missing the reference from xmlns:tools
Try to use another root element, as a constraint layout or even just layout as per example of google sunflowerapp:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/plant_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingLeft="@dimen/margin_normal"
android:paddingRight="@dimen/margin_normal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:context="com.google.samples.apps.sunflower.GardenActivity"
tools:listitem="@layout/list_item_plant" />
</layout>