How to create some margins around a CardView in a Recylerview

Issue I have the following XML layout file for a cardView that I then put into a Recylerview: <?xml version="1.0" encoding="utf-8"?> <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/cardView_itemLevel" android:layout_width="150dp" android:layout_height="150dp" xmlns:app="http://schemas.android.com/apk/res-auto" app:cardCornerRadius="10dp" android:layout_marginTop="12dp" android:layout_marginStart="12dp" android:layout_marginBottom="12dp" android:layout_marginEnd="12dp" app:cardPreventCornerOverlap="true" app:cardElevation="0dp" app:cardUseCompatPadding="false" app:contentPaddingBottom="2dp"> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent">

Continue reading

RecyclerView inside ScrollView is not working

Issue I’m trying to implement a layout which contains RecyclerView and ScrollView at the same layout. Layout template: <RelativeLayout> <ScrollView android:id="@+id/myScrollView"> <unrelated data>…</unrealated data> <android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/my_recycler_view" /> </ScrollView> </RelativeLayout> Problems: I can scroll until the last element of

Continue reading

How to show an empty view with a RecyclerView?

Issue I am used to put an special view inside the layout file as described in the ListActivity documentation to be displayed when there is no data. This view has the id “android:id/empty”. <TextView android:id=”@android:id/empty” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”@string/no_data” /> I

Continue reading