android 背景漸變色(shape,gradient) android
設置背景色能夠經過在res/drawable裏定義一個xml,xml
以下:utf-8
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="@color/colorleft" android:endColor="@color/colorRight" android:angle="0"/> </shape>
shape是用來定義形狀的,io
gradient定義該形狀裏面爲漸變色填充,coding
startColor起始顏色,di
endColor結束顏色,encoding
angle表示方向角度。當angle=0時,漸變色是從左向右。co
而後逆時針方向轉,當angle=90時爲從下往上。顏色