您的位置:首页 > 移动开发 > Android开发

android 最简单的方式实现旋转进度条

2015-07-09 15:51 543 查看
<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);


这样就完成了!可以说,实现这样的想过很简单。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: