<?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的值是比例,自己测试就好
参考:http://angrytools.com/android/button/