I try to use tools:listitem to show correctly styled sample-data on a RecyclerView. This works fine when using the original view.
But when extending RecyclerView to create my own custom view to add some functionality it just shows an empty space in the layout-preview in Android Studio.
How can I use all of the layout-preview stuff of a View when extending it?
My View looks like this:
class TestRecyclerView(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int
) : RecyclerView(context, attrs, defStyle) { }
Any ideas?
<com.test.my.TestRecyclerView
android:id="@+id/your_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/your_item"/>
Don't forget to put a app:layoutManager attribute in your custom RecyclerView!
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With