簡體   English   中英

卡在棒棒糖之前的版本中未在Android 5.0中間隔開

[英]Cards not spaced in Android 5.0, as they are in pre-lollipop

我在列表視圖中使用CardView作為行。 Android 4.0 -4.4中的卡間距適當,正好符合要求,但在Andorid 5.0中則不是。

以下是截圖:

對於Android 5.0:

http://i.imgur.com/70E8Tpf.png

預棒棒糖,以及我想要的方式:

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
    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"

您可以在這里閱讀有關內容-https: //developer.android.com/reference/android/support/v7/widget/CardView.html#attr_android.support.v7.cardview:cardUseCompatPadding

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM