Reputation: 181
I'm using CardView as rows in a listview. The cards in Android 4.0 -4.4 are well spaced, just as desired, but in Andorid 5.0, they aren't.
Here are the screenshots:
For Android 5.0:
https://i.sstatic.net/zSbjl.png
for pre-lollipop, and the way I want it:
https://i.sstatic.net/7qLhY.jpg
Here's the code for the CardView:
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:stateListAnimator="@anim/anim"
android:layout_margin="5dp"
android:clickable="true"
cardview:cardElevation="5dp"
cardview:cardBackgroundColor="@color/WhiteSmoke"
cardview:cardCornerRadius="10dp"
android:layout_height="wrap_content"
android:longClickable="true"
android:background="@android:drawable/dialog_holo_light_frame">
Here's the code for the listview these cards are a part of:
<ListView
android:id="@android:id/list"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:orientation="vertical">
What is it that's causing the cards to not be spaced on Android 5.0? I hope I've provided the information needed.
Thank you!
Upvotes: 2
Views: 616
Reputation: 181
Okay, I solved the issue by adding :
cardview:cardUseCompatPadding="true"
You can read about it here - https://developer.android.com/reference/android/support/v7/widget/CardView.html#attr_android.support.v7.cardview:cardUseCompatPadding
Upvotes: 7