5

我目前正在尝试使用 CardView 的 cardElevation 属性。虽然海拔和阴影在 KitKat 上完美运行,但它并没有出现在我的 Lollipop 设备上。这是我的 XML:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                xmlns:card_view="http://schemas.android.com/apk/res-auto"
                android:layout_width="match_parent"
                android:layout_height="72dp">

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        card_view:cardElevation="4dp"
        card_view:cardCornerRadius="2dp"
        card_view:cardUseCompatPadding="true">

        <!--Stuff on card view-->


    </android.support.v7.widget.CardView>
</RelativeLayout>
4

2 回答 2

3

您可以将cardUseCompatPadding设置为 true 以强制 CardView 为 L 中的阴影添加内部填充。

于 2014-12-31T07:11:44.673 回答
2

这是因为 Lollipop 上的阴影被CardView. 您需要添加一些填充到RelativeLayout或添加android:clipChildren="false"RelativeLayout.

于 2014-12-23T08:40:44.187 回答