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

标签 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_centerHorizontal="true"
    android:id="@+id/button"
    android:background="@drawable/button_background"
    android:minWidth="300dp"
    android:layout_marginTop="32dp"
    android:onClick="onClick"
    android:textColor="#fff"
    />

这是drawable

<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>

这是我目前拥有的:

What I have

这是我想要的:

What I want

最佳答案

你应该试试 This在你的按钮上制作渐变。

了解更多请点击Here

关于android - 如何为Android设计带有渐变和阴影的按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46106775/

相关文章:

javascript - 将 HTML 表格数据转换为 CSV 和 XML

twitter-bootstrap - 尝试通过 Bootstrap 按钮组点击触发平滑滚动

c++ win32 创建一个纯文本按钮

Android Gradle 在非调试版本上运行测试

android - 如何更改 Spinner 运行时的文本大小

android - 用户可以在未安装最新版本的情况下在 android 市场上发表评论吗?

html - <button> 在 &lt;input&gt; 字段内?

无论如何,Android 构建工具只会构建 x86_64。 APK 通过 adb 安装运行,但在 Play 商店中显示不兼容

xml - 是否可以使 Tokenizer 命名空间感知(使用 Splitter 时)

xml - XSLT 识别没有属性的 XML 标签元素