Android的View动画

今天我做手机摇一摇的动画

  /*
            0:开始的角度
            35:目的旋转角度
            Animation.RELATIVE_TO_SELF:相对于自己X点旋转
            0.5f:旋转X中心点
            Animation.RELATIVE_TO_SELF:相对于自己Y点旋转
            0.5f: 旋转Y中心点
        */
        RotateAnimation rotateAnimation=new RotateAnimation(
                0,35,
                Animation.RELATIVE_TO_SELF,0.5f,
                Animation.RELATIVE_TO_SELF,0.5f);
        //动画执行事件
        rotateAnimation.setDuration(200);
        //Animation.RESTART: 开始-->结束,开始-->结束
        //Animation.REVERSE:开始-->结束-->开始
        rotateAnimation.setRepeatMode(Animation.REVERSE);
        //重复动画的次数,-1:无限次循环
        rotateAnimation.setRepeatCount(5);
        //iv:ImageView控件,开始执行动画
        iv.startAnimation(rotateAnimation);
posted @ 2016-11-23 17:58  我的网名  阅读(26)  评论(0)    收藏  举报