shape用于設(shè)定形狀,可以在selector,layout等里面使用,有6個子標(biāo)簽,各屬性如下: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas./apk/res/android" > <!-- 圓角 --> <corners android:radius="9dp" android:topLeftRadius="2dp" android:topRightRadius="2dp" android:bottomLeftRadius="2dp" android:bottomRightRadius="2dp"/><!-- 設(shè)置圓角半徑 --> <!-- 漸變 --> <gradient android:startColor="@android:color/white" android:centerColor="@android:color/black" android:endColor="@android:color/black" android:useLevel="true" android:angle="45" android:type="radial" android:centerX="0" android:centerY="0" android:gradientRadius="90"/> <!-- 間隔 --> <padding android:left="2dp" android:top="2dp" android:right="2dp" android:bottom="2dp"/><!-- 各方向的間隔 --> <!-- 大小 --> <size android:width="50dp" android:height="50dp"/><!-- 寬度和高度 --> <!-- 填充 --> <solid android:color="@android:color/white"/><!-- 填充的顏色 --> <!-- 描邊 --> <stroke android:width="2dp" android:color="@android:color/black" android:dashWidth="1dp" android:dashGap="2dp"/> </shape> 填充:設(shè)置填充的顏色 間隔:設(shè)置四個方向上的間隔 大?。?/font>設(shè)置大小 圓角:同時設(shè)置五個屬性,則Radius屬性無效 android:Radius="20dp" 設(shè)置四個角的半徑 android:topLeftRadius="20dp" 設(shè)置左上角的半徑
描邊:dashWidth和dashGap屬性,只要其中一個設(shè)置為0dp,則邊框為實現(xiàn)邊框 android:width="20dp" 設(shè)置邊邊的寬度
漸變:當(dāng)設(shè)置填充顏色后,無漸變效果。angle的值必須是45的倍數(shù)(包括0),僅在type="linear"有效,不然會報錯。android:useLevel 這個屬性不知道有什么用。 angle對應(yīng)值的起點(diǎn)如圖: |
|