关闭状态


打开状态

切换有500秒动画

初始化恢复打开关闭状态时,动画durationMillis设置为0

   private void rotateOpen(final View v,long durationMillis) {        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 animation = new RotateAnimation(0f, 180f, Animation.RELATIVE_TO_SELF,                0.5f, Animation.RELATIVE_TO_SELF, 0.5f);        animation.setDuration(durationMillis);//设置动画持续时间/** 常用方法 */        //animation.setRepeatCount(0);//设置重复次数        //animation.setStartOffset(long startOffset);//执行前的等待时间        //animation.setFillAfter(true);//动画执行完后是否停留在执行完的状态        animationSet.addAnimation(animation);        animationSet.setFillAfter(true);        animationSet.setAnimationListener(new Animation.AnimationListener() {            @Override            public void onAnimationStart(Animation animation) {            }            @Override            public void onAnimationEnd(Animation animation) {                // v.clearAnimation();                // v.setRotation(180f);            }            @Override            public void onAnimationRepeat(Animation animation) {            }        });        // v.setAnimation(animation);        // animation.startNow();        v.startAnimation(animationSet);    }
  private void rotateClose(final View v,long durationMillis) {        //        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 animation = new RotateAnimation(180f, 360f, Animation.RELATIVE_TO_SELF,                0.5f, Animation.RELATIVE_TO_SELF, 0.5f);        animation.setDuration(durationMillis);//设置动画持续时间        //animation.setRepeatCount(0);//设置重复次数        //animation.setStartOffset(long startOffset);//执行前的等待时间        //animation.setFillAfter(true);//动画执行完后是否停留在执行完的状态        animationSet.addAnimation(animation);        animationSet.setFillAfter(true);        // v.setAnimation(animation);        // animation.startNow();        v.startAnimation(animationSet);    }

视图动画只改变样子不改变原有属性,所以比较长。。。

简单快速实现见:

Android 点击View Rotate旋转带视图动画
http://blog.csdn.net/RichieZhu/article/details/52201679

更多相关文章

  1. android 多通知 参数问题, PendingIntent:有用的requestCode参数
  2. Android(安卓)UI 之 RecyclerView实现常见首页布局
  3. android 中关于SimpleAdapter构造参数的问题
  4. Android:为什么声明控件和控件赋值要分开?
  5. Android(安卓)程式开发:(十)基本控件 —— 10.2 Button,ImageButton
  6. Android控件之AutoCompleteTextView(自动匹配输入的内容)
  7. Android应用之PopupWindow显示位置详解
  8. Android(安卓)Toolbar控件
  9. Android控件复习之TextView与EditText

随机推荐

  1. 利用uWSGI和Nginx部署Django
  2. Python内置函数之匿名(lambda)函数
  3. python——爬虫实战(一)
  4. Flask-RESTful与Flask-WTF形式集成
  5. pylogin系列之V2EX自动领币消息提醒
  6. 如何获得正在运行的Python脚本的路径?(复
  7. 即使我返回2个变量,对象也不可迭代?
  8. 基于python的opcode优化和模块按需加载机
  9. Python ElementTree“找不到元素”异常
  10. 使用Python编写简单的端口扫描器的实例分