我将 CardView 用作 ListView 中的行。 Android 4.0 -4.4 中的卡片间距合理,符合要求,但在 Andorid 5.0 中则不然。
截图如下:
对于安卓 5.0:
http://i.imgur.com/70E8Tpf.png
对于前 Lollipop ,以及我想要的方式:
http://i.imgur.com/9UsJc1o.jpg?1
这是 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">
这是这些卡片所属的 ListView 的代码:
<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">
是什么导致卡片在 Android 5.0 上没有间隔?我希望我已经提供了所需的信息。
谢谢!
最佳答案
好的,我通过添加解决了这个问题:
cardview:cardUseCompatPadding="true"
关于java - 卡片在 Android 5.0 中没有间隔,因为它们在 Lollipop 之前,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27440721/