Android 如何使cardview仅显示底部阴影

Android 如何使cardview仅显示底部阴影,android,Android,我使用以下代码: <android.support.v7.widget.CardView xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" app:cardUseCompatPadding="true" app:c

我使用以下代码:

<android.support.v7.widget.CardView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:cardUseCompatPadding="true"
        app:cardElevation="4dp">
    <TextView android:text="in card view" android:layout_width="match_parent" android:layout_height="wrap_content"/>
</android.support.v7.widget.CardView>


如何仅使底部显示阴影?

如果需要线性阴影,请尝试以下操作:

<View
    android:id="@+id/shadow"
    android:layout_width="match_parent"
    android:layout_height="3dp"
    android:background="@drawable/down_shadow"
    />

down_shadow.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    >

    <gradient
        android:angle="-90"
        android:endColor="#EEEEEE"
        android:startColor="#FFFFFF"
        />

</shape>


有关手动设置阴影的内容,请参见不同的文章:。

控制阴影会很好,也希望找到相同的答案删除此行应用程序:carducecompatipadding=“true”@Benjamin,它会改变什么?