今天要做一个Android RotateAnimation动画,但仿照一个demo做了下死活没有旋转效果,通过认真比对终于找出问题了,原来是imageview的id不能使img_arrow,换个id为img_catogery_arrow就可以了哦你onCreate中绑定点击事件

private LinearLayout mLinearLayout;private ImageView mImageUnfold;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);mLinearLayout=(LinearLayout) findViewById(R.id.layout_cid);mImageUnfold=(ImageView)findViewById(R.id.img_catogery_arrow);mLinearLayout.setOnClickListener(new RotateButtonListener());}
点击事件中实现动画效果
class RotateButtonListener implements OnClickListener{       public void onClick(View v) {           AnimationSet animationSet = new AnimationSet(true);           //参数1:从哪个旋转角度开始           //参数2:转到什么角度           //后4个参数用于设置围绕着旋转的圆的圆心在哪里           //参数3:确定x轴坐标的类型,有ABSOLUT绝对坐标、RELATIVE_TO_SELF相对于自身坐标、RELATIVE_TO_PARENT相对于父控件的坐标           //参数4:x轴的值,0.5f表明是以自身这个控件的一半长度为x轴           //参数5:确定y轴坐标的类型           //参数6:y轴的值,0.5f表明是以自身这个控件的一半长度为x轴           RotateAnimation rotateAnimation = new RotateAnimation(0, 360,                  Animation.RELATIVE_TO_SELF,0.5f,                  Animation.RELATIVE_TO_SELF,0.5f);           rotateAnimation.setDuration(1000);           animationSet.addAnimation(rotateAnimation);           image.startAnimation(animationSet);       }    }

更多相关文章

  1. Android重写View并且自定义属性(二)
  2. Android(安卓)Studio 常用控件和常用布局的介绍
  3. Android调用第三方百度APP进行导航
  4. android 调用系统命令实现关机
  5. Recovery模式的命令行参数
  6. android在学习——Menu背景图片,背景色的设置
  7. Android(安卓)pcm文件播放方法(AudioTrack)
  8. android播放网络或者本地视频(截取某帧做封面)VideoView原生控件
  9. Android(安卓)编程下 Touch 事件的分发和消费机制(一)

随机推荐

  1. Android手机操作系统中实现图片浏览
  2. 谷歌升级手机Android商城 趋向社交网络应
  3. Android的View类使用
  4. Android:Google的阳谋和Apache Harmony
  5. 图解 Android Handler 线程消息机制
  6. 【android工程转为lib工程后提示'R.id.xx
  7. Android沉浸式状态栏下,如何代码实现andro
  8. Android开发资料推荐之Google Android开
  9. android悬浮窗的两种实现方案
  10. Android开发之Android体系架构介绍