圆形:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:useLevel="false">
<solid android:color="@color/deep_gray" />
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="@color/backg_gray" />
<size
android:width="30dp"
android:height="30dp" />
</shape>
效果图:
转圈圈:
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" > <shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="10"
android:useLevel="false" >
<gradient
android:centerColor="#FF6A6A"
android:endColor="#FF0000"
android:startColor="#FFFFFF"
android:type="sweep" />
</shape> </rotate>
效果图, 会转圈圈:
注意:如果在控件中没有设置宽和高,例如:控件设置了wrap_content,就需要在shape中设置宽和高:
<size
android:width="30dp"
android:height="30dp" />
完整代码:
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" > <shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="10"
android:useLevel="false" >
<gradient
android:centerColor="@color/backg_gray"
android:endColor="@color/deep_gray"
android:startColor="#FFFFFF"
android:type="sweep" /> <size
android:width="30dp"
android:height="30dp" /> </shape> </rotate>