1、在resource文件夾的drawable文件中新建一個(gè)shape的xml文件
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
//android:angle="45" 漸變的方向 默認(rèn)為0 從做向右 亚脆,90時(shí)從下向上 必須為45的整數(shù)倍
// android:type="radial" 漸變類型 有三種 線性linear 放射漸變r(jià)adial 掃描線性漸變sweep
// android:centerX="0.5" 漸變中心相對(duì)X坐標(biāo)只有漸變類型為放射漸變時(shí)有效
// android:centerY="0.5" 漸變中心相對(duì)Y坐標(biāo)只有漸變類型為放射漸變時(shí)有效
// android:gradientRadius="100" 漸變半徑 非線性放射有效
<gradient
android:angle="0"http://從左到友漸變
android:endColor="#FF38C9"http://結(jié)束顏色
android:startColor="#B463FF" />//開始顏色
</shape>
效果圖
$(EIU8@(HT2N2~SR50AC51L.png