<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="270"
android:centerColor="#00FF00"
android:centerX="50%"
android:centerY="50%"
android:endColor="#ffffff"
android:startColor="#FF7700"
android:type="linear" />
</shape>
再你的res/drawable/文件夾下,創建bg_gradient_orange_green_white.xml文件,內容如上
並將該文件設置你使用的空間的background屬性即可
這個是三色效果,通過設置角度270,從上到下,由橙變綠再變白
如果只需要兩色的話,只需要把帶center的屬性去掉即可,xy的值是比例,自己測試就好