带底部边框的卡片视图

cardview with bottom border

我想要一个只有底部边框的卡片视图。 所以我找到了解决方案:

toolbar_background.xml :

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item>
        <shape android:shape="rectangle" >
            <solid android:color="@color/colorPrimary" />
        </shape>
    </item>

    <item android:top="-2dp" android:right="-2dp" android:left="-2dp">
        <shape>
            <solid android:color="@android:color/transparent" />
            <stroke
                android:width="1dp"
                android:color="@color/titleBarBorder" />
        </shape>
    </item>

</layer-list>

然后我使用 android:background="@drawable/toolbar_background" 将此 .xml 添加到我的 cardview 作为背景,但颜色不会显示,cardview 将以白色背景呈现。我究竟做错了什么 ?

我使用图像视图将背景 xml 设置为卡片视图:

<android.support.v7.widget.CardView
            android:layout_alignParentTop="true"
            android:layout_width="match_parent"
            android:layout_height="70dp"
            app:cardBackgroundColor="@color/colorPrimary"
            app:cardElevation="4dp"
            app:cardCornerRadius="0dp">

                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:src="@drawable/toolbarbackground"
                    android:scaleType="fitXY"/>

                <cardview contents here>...

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