Android:将渐变可绘制对象设置为背景时,按钮上缺少高度

Android: Elevation missing on button when setting a gradient drawable as background

我有一个 Button 并且我将渐变可绘制对象设置为背景。 具有渐变可绘制对象的按钮缺少高度,而所有其他按钮都有高度。

为什么带有可绘制渐变的按钮上缺少高度?有什么简单的方法可以解决这个问题吗?

我的代码如下所示:

gradient.xml

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

    <item>

        <shape xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle">

            <gradient
                android:type="radial"
                android:gradientRadius="250dp"
                android:startColor="@color/blue"
                android:endColor="@color/red"/>

            <corners android:radius="@dimen/round_corner_radius"/>

            <stroke
                android:width="5dp"
                android:color="@android:color/transparent"/>

        </shape>

    </item>

    <item android:top="7dp"
        android:left="7dp"
        android:right="7dp"
        android:bottom="7dp">

        <shape android:shape="rectangle" >

            <solid android:color="#88ffffff"/>
            <corners android:radius="@dimen/round_corner_radius"/>

        </shape>

    </item>

</layer-list>

activity.xml

...
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/button"
        android:background="@drawable/gradient"/>
...

我解决了我的问题。我不得不删除

<stroke
    android:width="5dp"
    android:color="@android:color/transparent"/>

问题可能是设置的颜色。没有描边按钮的行为就像一个普通的凸起按钮。