<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">先看效果图:</span>
要达到这样的效果,很简单,其原理就是将用ImageView显示一张图片,然后给ImageView添加围绕中心旋转的的动画即可,主要代码如下:
</pre><pre name="code" class="html"><ImageView
android:id="@+id/iv_pre_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/pre_loading"
/>
其中 drawable/pre_loading 就是旋转的图片,png格式就行!
在Activity里面设置旋转动画即可:
Animation mRotateAnimation = new RotateAnimation(0.0f, 720.0f, Animation.RELATIVE_TO_SELF, 0.5f,Animation.RELATIVE_TO_SELF, 0.5f);
mRotateAnimation.setFillAfter(true);
mRotateAnimation.setInterpolator(new LinearInterpolator());
mRotateAnimation.setDuration(1200);
mRotateAnimation.setRepeatCount(Animation.INFINITE);
mRotateAnimation.setRepeatMode(Animation.RESTART);
findViewById(R.id.iv_pre_loading).setAnimation(mRotateAnimation);
这样就完成了!可以说,实现这样的想过很简单。