android旋转动画开源库,实现Android简单动画旋转案例源码

利用android实现了简单旋转动画,效果如下,从左到右,3个状态,最终图片旋转180度:

06169b769f26b571300b3cf1651ccee3.png

23a6a7b07323fecddb09ef8bf10609b3.png

旋转动画利用的是RotateAnimation实现的。布局文件main.xml代码:

android:orientation="vertical" android:id="@+id/mContener"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

>

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:src="@drawable/tiankong"

android:onClick="showAnimation"

/>   android:onClick="showAnimation" 代码作用是在点击ImageView的时候,调用MainActivity中的showAnimation方法,showAnimation方法如下:

public void showAnimation(View view) {

Log.v(TAG, "showContent>>>");

final float centerX = mView.getWidth() / 2.0f;

final float centerY = mView.getHeight() / 2.0f;

RotateAnimation rotateAnimation = new RotateAnimation(0, 180, centerX,

centerY);

rotateAnimation.setDuration(1000 * 20);

rotateAnimation.setFillAfter(true);

mView.startAnimation(rotateAnimation);

}   解释一下:

new RotateAnimation(0, 180, centerX,centerY);   第一个参数表示动画的起始角度,第二个参数表示动画的结束角度,第三个表示动画的旋转中心x轴,第四个表示动画旋转中心y轴。

rotateAnimation.setDuration(1000 * 20);   表动画持续20s。

rotateAnimation.setFillAfter(true);   ture表示动画结束后停留在动画的最后位置,false表示动画结束后回到初始位置,默认为false。

mView.startAnimation(rotateAnimation);

86824163e2775e3159b02e958ade6385.png

ef53c48f4af8c4f938442bdc44fa6b00.png

ebb90bcfb869766324f03fa41ca85e39.png

40c450b2c72ded7d4865923bff8631f5.png

转载:http://www.adobex.com/android/source/details/00000231.htm

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值