定义一个按钮布局:背景直接可以用一个圆圈加载图片。
<Button
android:id="@+id/refresh_button"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginRight="15dp"
android:background="@mipmap/rotate" />
在代码中找到这个按钮后,在按钮的事件中写下以下方法:
final RotateAnimation animation = new RotateAnimation(0.0f, 720.0f,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
animation.setDuration(1500);
refresh_button.startAnimation(animation);
OK了。到此你的按钮就可以旋转了。