渐变效果主要通过 gradient
参数实现,圆角效果通过 corners
.
两种颜色渐变效果实现代码如下:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:endColor="#F9CE97"
android:startColor="#FFECD7" />
<corners
android:topLeftRadius="8dp"
android:topRightRadius="8dp" />
</shape>
实现效果如图:
三种颜色渐变代码:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:centerColor="#FCEDDD"
android:endColor="#FBD2B6"
android:startColor="#FDE0BD" />
<corners
android:topLeftRadius="8dp"
android:topRightRadius="8dp" />
</shape>
实现效果如图: