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

<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);


这样就完成了!可以说,实现这样的想过很简单。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值