android 背景渐变色

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时为从下往上。颜色

相关文章
相关标签/搜索