一.圓角矩形
<?xml version="1.0" encoding="utf-8"?>
<!-- android:shape指定形狀類型,默認(rèn)為rectangle -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- solid設(shè)置填充色 -->
<solid android:color="#36a3d9" />
<!-- corners設(shè)置圓角-->
<corners android:radius="10dp" />
</shape>
二.鏤空描邊矩形
<?xml version="1.0" encoding="utf-8"?>
<!-- android:shape指定形狀類型 -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- solid設(shè)置填充色 -->
<solid android:color="#0036a3d9" />
<!-- corners設(shè)置圓角-->
<corners android:radius="10dp" />
<!-- 設(shè)置邊框 -->
<stroke android:color="#36a3d9" android:width="5dp" />
</shape>
詳細(xì)屬性說(shuō)明
solid: 設(shè)置填充的顏色索守,只有android:color一個(gè)屬性
android:color 填充的顏色
padding: 設(shè)置內(nèi)間距
android:left 左內(nèi)間距
android:right 右內(nèi)間距
android:top 上內(nèi)間距
android:bottom 下內(nèi)間距
gradient: 設(shè)置漸變顏色倚聚,可以是線性漸變事镣、輻射漸變或南、掃描性漸變
android:type 漸變的類型
linear 線性漸變驳规,默認(rèn)
radial 放射漸變肴敛,設(shè)置該項(xiàng)時(shí),android:gradientRadius也必須設(shè)置
sweep 掃描性漸變
android:startColor 漸變開始的顏色
android:endColor 漸變結(jié)束的顏色
android:centerColor 漸變中間的顏色
android:angle 漸變的角度吗购,線性漸變時(shí)才有效医男,必須是45的倍數(shù),0表示從左到右捻勉,90表示從下到上
android:centerX 漸變中心的相對(duì)X坐標(biāo)镀梭,放射漸變時(shí)才有效,在0.0到1.0之間踱启,默認(rèn)為0.5报账,表示在正中間
android:centerY 漸變中心的相對(duì)X坐標(biāo)研底,放射漸變時(shí)才有效,在0.0到1.0之間透罢,默認(rèn)為0.5榜晦,表示在正中間
android:gradientRadius 漸變的半徑,只有漸變類型為radial時(shí)才使用
android:useLevel 如果為true琐凭,則可在LevelListDrawable中使用
corners: 設(shè)置圓角芽隆,只適用于rectangle類型,可分別設(shè)置四個(gè)角不同半徑的圓角
android:radius 圓角半徑
android:topLeftRadius 左上角的半徑
android:topRightRadius 右上角的半徑
android:bottomLeftRadius 左下角的半徑
android:bottomRightRadius 右下角的半徑
stroke: 設(shè)置描邊统屈,實(shí)線或虛線。
android:color 描邊顏色
android:width 描邊寬度
android:dashWidth 虛線的橫線長(zhǎng)度
android:dashGap 虛線的距離