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

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

  <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"  android:orientation="vertical" android:id="@+id/mContener"  android:layout_width="fill_parent"  android:layout_height="fill_parent"  >  <imageview android:id="@+id/picture_tiankong"  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);


实现Android简单动画旋转案例源码 在此处下载源码

 实现Android简单动画旋转案例源码
实现Android简单动画旋转案例源码
实现Android简单动画旋转案例源码


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

更多相关文章

  1. Android——属性动画(Property Animation)
  2. 【源码分享下载】每日更新之Android应用源码之仿微信5.2布局
  3. Android launcher3 -- launcher3源码1
  4. Android Binder机制 - defaultServiceManager()源码分析
  5. Android源码下载出现的问题
  6. 转android四种动画
  7. Android 经典的魔塔游戏源码
  8. Android的Activity动画切换

随机推荐

  1. Android(安卓)初学者入门(一个最简单的应
  2. Android(安卓)XML解析学习——Sax方式
  3. 申请Android Map 的API Key(v2)的最新申
  4. portrait表示横向,landscape表示纵向
  5. Android动态污点分析工具TaintDroid部署
  6. android 中文 api (87) —— BaseInputConn
  7. Android中文API(116)――TableLayout
  8. android app崩溃日志收集以及上传
  9. context对于android的重要意义
  10. android以及ios平台的开发工具设想