android - adding gradient colour to button background in android
问题描述
I have a gradient background with code:
<Button android:id="@+id/btn_signup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Login"
android:background="@drawable/sel_btn_background"
android:gravity="center"
android:textSize="16sp"
android:layout_marginTop="40dp"
android:textColor="@android:color/white"/>
sel_btn_background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="@color/bluegreen"
android:endColor="@color/aqua_marine"
android:angle="-270" />
</shape>
I get result:
How to achieve the below result(left side is the light colour fading to dark on right colour) What value should be added for angle:
解决方案
使用 180 角度而不是 -270 角度
android:angle="360"