关于Shape使用的官方文档:
http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape
Android中常常使用shape来定义控件的一些显示属性,下面是Shape中的所有属性:
1.<?xml version="1.0" encoding="utf-8"?>
2.<shape
3. xmlns:android="http://schemas.android.com/apk/res/android"
4. android:shape=["rectangle" | "oval" | "line" | "ring"] >
5. <corners
6. android:radius="integer"
7. android:topLeftRadius="integer"
8. android:topRightRadius="integer"
9. android:bottomLeftRadius="integer"
10. android:bottomRightRadius="integer" />
11. <gradient
12. android:angle="integer"
13. android:centerX="integer"
14. android:centerY="integer"
15. android:centerColor="integer"
16. android:endColor="color"
17. android:gradientRadius="integer"
18. android:startColor="color"
19. android:type=["linear" | "radial" | "sweep"]
20. android:useLevel=["true" | "false"] />
21. <padding
22. android:left="integer"
23. android:top="integer"
24. android:right="integer"
25. android:bottom="integer" />
26. <size
27. android:width="integer"
28. android:height="integer" />
29. <solid
30. android:color="color" />
31. <stroke
32. android:width="integer"
33. android:color="color"
34. android:dashWidth="integer"
35. android:dashGap="integer" />
36.</shape>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<!-- 渐变 -->
<gradient android:endColor="#FFFFFF" android:gradientRadius="50" android:startColor="#ff8c00" android:type="radial" />
<!-- 描边 -->
<stroke android:dashGap="3dp" android:dashWidth="5dp" android:width="2dp" android:color="#dcdcdc" />
<!-- 圆角 -->
<corners android:radius="2dp" />
<padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />
</shape>
</item>
<item android:state_focused="true">
<shape>
<gradient android:angle="270" android:endColor="#ffc2b7" android:startColor="#ffc2b7" />
<stroke android:width="2dp" android:color="#dcdcdc" />
<corners android:radius="2dp" />
<padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />
</shape>
</item>
<item>
<shape>
<solid android:color="#ff9d77" />
<stroke android:width="2dp" android:color="#fad3cf" />
<corners android:bottomLeftRadius="5dp" android:bottomRightRadius="0dp" android:topLeftRadius="0dp" android:topRightRadius="5dp" />
<padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />
</shape>
</item>
</selector>