How do I decrease the space between cards in a CardView within a RecyclerView?
Edit these attributes
card_view:cardMaxElevation="1dp"
card_view:cardElevation="1dp"
so full code will be
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="200dp"
card_view:cardCornerRadius="5dp"
card_view:cardMaxElevation="1dp"
card_view:cardElevation="1dp"
card_view:cardBackgroundColor="@color/colorPrimary"
card_view:cardUseCompatPadding="true"
card_view:cardPreventCornerOverlap="false"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/card_list">
<ImageView
android:id="@+id/thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:src="@drawable/bag"
android:contentDescription="string/video_thumbnail_description"
android:layout_weight="1"
/>
<TextView
android:id="@+id/video_title_view"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="lovelksdjslkdjlsdj"
android:layout_weight="3"
/>
</LinearLayout>
</android.support.v7.widget.CardView>
I experiment a little bit with this, and for me...
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
android:id="@+id/card_view"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardCornerRadius="4dp"
app:cardElevation="1dp"
app:cardMaxElevation="1dp"
app:cardUseCompatPadding="true" > //this line is game changer
Happy codding