天天看點

Android:xml實作漸變

 drawble檔案夾下面建立,xxx.xml内容如下

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:angle="200"
        android:centerColor="#EBFDEF"
        android:endColor="#EBFDEF"
        android:startColor="#A3FCB5" />
    <corners android:radius="30dp" />
</shape>
           

效果如下圖

Android:xml實作漸變

如果說,我隻要下面兩個是圓角,這樣就可以

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:angle="200"
        android:centerColor="#EBFDEF"
        android:endColor="#EBFDEF"
        android:startColor="#A3FCB5" />
    <corners
        android:topLeftRadius="0dp"
        android:topRightRadius="0dp"
        android:bottomRightRadius="20dp"
        android:bottomLeftRadius="20dp"
        />

</shape>