標籤:android style blog http color 使用
shape用於設定形狀,可以在selector,layout等裡面使用,有6個子標籤,各屬性如下:
1 <?xml version="1.0" encoding="utf-8"?> 2 <shape xmlns:android="http://schemas.android.com/apk/res/android" > 3 4 <!-- 圓角 --> 5 <corners 6 android:radius="9dp" 7 android:topLeftRadius="2dp" 8 android:topRightRadius="2dp" 9 android:bottomLeftRadius="2dp"10 android:bottomRightRadius="2dp"/><!-- 設定圓角半徑 -->11 12 <!-- 漸層 -->13 <gradient14 android:startColor="@android:color/white"15 android:centerColor="@android:color/black"16 android:endColor="@android:color/black"17 android:useLevel="true"18 android:angle="45"19 android:type="radial"20 android:centerX="0"21 android:centerY="0"22 android:gradientRadius="90"/>23 24 <!-- 間隔 -->25 <padding26 android:left="2dp"27 android:top="2dp"28 android:right="2dp"29 android:bottom="2dp"/><!-- 各方向的間隔 -->30 31 <!-- 大小 -->32 <size33 android:width="50dp"34 android:height="50dp"/><!-- 寬度和高度 -->35 36 <!-- 填充 -->37 <solid38 android:color="@android:color/white"/><!-- 填充的顏色 -->39 40 <!-- 描邊 -->41 <stroke42 android:width="2dp"43 android:color="@android:color/black"44 android:dashWidth="1dp"45 android:dashGap="2dp"/>46 47 </shape>
填充:設定填充的顏色
間隔:設定四個方向上的間隔
大小:設定大小
圓角:同時設定五個屬性,則Radius屬性無效
android:Radius="20dp" 設定四個角的半徑
android:topLeftRadius="20dp" 設定左上方的半徑
android:topRightRadius="20dp" 設定右上方的半徑
android:bottomLeftRadius="20dp" 設定右下角的半徑
android:bottomRightRadius="20dp" 設定左下角的半徑
描邊:dashWidth和dashGap屬性,只要其中一個設定為0dp,則邊框為實現邊框
android:width="20dp" 設定邊邊的寬度
android:color="@android:color/black" 設定邊邊的顏色
android:dashWidth="2dp" 設定虛線的寬度
android:dashGap="20dp" 設定虛線的間隔寬度
漸層:當設定填充顏色後,無漸層效果。angle的值必須是45的倍數(包括0),僅在type="linear"有效,不然會報錯。android:useLevel 這個屬性不知道有什麼用。
angle對應值的起點
ps:http://www.cnblogs.com/cyanfei/archive/2012/07/27/2612023.html