android 常用渐变背景绘制

从上到下绘制如图所示

      

1 <?xml version="1.0" encoding="utf-8"?>
2 <shape xmlns:android="http://schemas.android.com/apk/res/android"
3     android:shape="rectangle">
4     <gradient
5         android:angle="270"
6         android:endColor="#20a7ea"
7         android:startColor="#4adcf9" />
8 </shape>

从左到右绘制渐变色如图所示

      

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
 3     <gradient android:startColor="#F8CE64" android:endColor="#FCAD79"/>
 4     <corners android:radius="24dp" />
 5 
 6     <corners
 7         android:bottomLeftRadius="20dip"
 8         android:bottomRightRadius="20dip"
 9         android:topLeftRadius="0dip"
10         android:topRightRadius="0dip" />
11 
12 </shape>
原文地址:https://www.cnblogs.com/monkey0928/p/9258629.html