xml實現(xiàn)圓角

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <corners android:radius="5dp" />

    <size
        android:height="30dp"
        android:width="20dp" />

    <gradient
        android:startColor="#9933cc"
        android:endColor="#aa66cc"
        android:angle="45"
        />

    <padding android:left="5dp"
        android:right="5dp"
        android:top="5dp"
        android:bottom="5dp"/>

</shape>
image.png

solid

描述:內(nèi)部填充
屬性:android:color 填充顏色

size

   描述:大小
   屬性:
             android:width 寬
             android:height 高

gradient

    描述:漸變色
    屬性:
               android:startColor漸變起始顏色
               android:endColor漸變結(jié)束顏色
               android:centerColor漸變中間顏色
               android:angle 漸變的角度,angle=0時,漸變色是從左向右,然后逆時針方向轉(zhuǎn);當(dāng)angle=90時,漸變色從上往下。angle必然是45的倍數(shù)
               android:type 漸變類型:linear(線性)、radial(放射性,以開始色為中心)、sweep(掃描線式漸變)
               android:userLevel如果要使用LevelListDrawable對象,就要設(shè)置為true。設(shè)置true無漸變色,false有漸變色
               android:grdientRadial漸變半徑,只有設(shè)置type為radial時,此值才生效
               android:centerX 漸變中心X點(diǎn)坐標(biāo)的相對位置
               android:centerY 漸變中心Y點(diǎn)坐標(biāo)的相對位置 

stroke

    描述:描邊
    屬性: 
               android:width 描邊寬度
               android:color 描邊顏色
               android:dashwidth描邊樣式為虛線時的寬度,值為0時為實線,值大于0時為虛線
               android:dashGap 描邊為虛線時,虛線之間的間隔

corners

    描述:圓角
    屬性:
               android:radius 四個角半徑值
               android:topLeftRadius左上角半徑值
               android:topRightRadius右上角半徑值
               android:bottomLeftRadius右下角半徑值
               android:bottomRightRadius左下角半徑值

padding

    描述:內(nèi)邊距
    屬性:
               android:left 左內(nèi)邊距
               android:right 右內(nèi)邊距
               android:top 上內(nèi)邊距
               android:bottom 下內(nèi)邊距
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容