如何为Android设计带有渐变和阴影的按钮?

如何为Android设计带有渐变和阴影的按钮?,android,xml,button,colors,Android,Xml,Button,Colors,我如何在Android中创建如下按钮?在大多数情况下,我已经按下了按钮的主要部分。我似乎无法理解阴影和点击动画 钮扣 <Button android:text="Connect" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/connectionStatus" android:layout_cent

我如何在Android中创建如下按钮?在大多数情况下,我已经按下了按钮的主要部分。我似乎无法理解阴影和点击动画

钮扣

<Button
    android:text="Connect"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/connectionStatus"
    android:layout_centerHorizontal="true"
    android:id="@+id/button"
    android:background="@drawable/button_background"
    android:minWidth="300dp"
    android:layout_marginTop="32dp"
    android:onClick="onClick"
    android:textColor="#fff"
    />

这是抽屉

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#21D4FD"
        android:endColor="#B721FF"
        android:angle="45"
    />
    <corners android:bottomLeftRadius="20dip"
        android:topRightRadius="20dip"
        android:topLeftRadius="20dip"
        android:bottomRightRadius="20dip"
    />
</shape>

这就是我目前拥有的:

这就是我想要的:

您应该尝试在按钮上设置渐变


要了解更多信息,请单击“查看立面”以获得阴影效果。就我所关心的按钮而言,您可能希望使用带有渐变的ImageButtons,这些渐变是从Photoshop等软件嵌入的。