首页 > 解决方案 > 为按钮着色的渐变替代方案

问题描述

我在 android 按钮中有一个形状,我希望它有两种颜色。但不是渐变。只是颜色,怎么做?下面是我的drawable。我不想要它渐变,只是两种颜色。

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
    <gradient
        android:angle="0"
        android:endColor="#e574bd"
        android:startColor="#874dbc"
        android:type="linear" />
    <corners
        android:radius="20dp"/>
</shape>

编辑:我附上了我想要的图片在此处输入图像描述

 <RelativeLayout
                    android:id="@+id/registration"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/buttonHeight"
                    android:paddingEnd="@dimen/default_margin"
                    android:paddingStart="@dimen/default_margin"
                    android:background="@drawable/abovexml"
                    android:gravity="center_horizontal">
                    <ImageView
                        android:layout_width="match_parent"
                        android:id="@+id/sadad2"
                        android:src="@+id/theimagewithoutwordingchangepassword"
                        android:scaleType="fitXY"
                        android:layout_height="@dimen/buttonHeight"/>
                    <TextView
                        android:id="@+id/loginText"
                        android:layout_width="match_parent"
                        android:layout_height="@dimen/buttonHeight"
                        android:layout_centerInParent="true"
                        android:gravity="center"
                        android:text="@string/changepass"
                        android:textColor="@android:color/white"
                        android:textSize="@dimen/buttonSize"></TextView>
                </RelativeLayout>

标签: androidbutton

解决方案


推荐阅读