<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="5dip" android:color="#FFFF00" /><!-- 描邊 :邊框寬度與顏色 -->
<padding android:left="20dip" android:top="0dip" android:right="0dip" android:bottom="0dip" /><!-- 主要內容的padding 文字距離上下左右的距離 -->
<corners android:topLeftRadius="15dip"
android:topRightRadius="15dip"
android:bottomLeftRadius="0dip"
android:bottomRightRadius="0dip"/><!-- 圓角的半徑 也可以統一設置半徑 android:radius="9dip"-->
<gradient android:startColor="#ff8c00" android:endColor="#FFFFFF" android:angle="270" /> <!-- 漸變 -->
<solid android:color="#FFEFD5" /> <!-- 沒有描邊的中間部分 --><!--solid 與 gradient 只能顯示在代碼最后那個-->
</shape>
更多說明:
gradient:漸變
android:startColor和android:endColor分別為起始和結束顏色,ndroid:angle是漸變角度,必須為45的整數倍。
另外漸變默認的模式為android:type="linear",即線性漸變,可以指定漸變為徑向漸變,android:type="radial",徑向漸變需要指定半徑android:gradientRadius="50"。
stroke:描邊
android:width="2dp" 描邊的寬度,android:color 描邊的顏色。
我們還可以把描邊弄成虛線的形式,設置方式為:
android:dashWidth="5dp"
android:dashGap="3dp"
其中android:dashWidth表示'-'這樣一個橫線的寬度,android:dashGap表示之間隔開的距離。