仿IPhone 长按图标删除应用,图标抖动效果

仿IPhone 长按图标删除应用,图标抖动效果

使用ValueAnimator类实现,长点击图标,图标抖动的效果,可以自己规定抖动的程度大小。

由于Animator类是在android3.0之后才加上去的,所以,为了兼容3.0以下的机子,就导入了nineoldandroid.jar包,实现兼容。

工程源代码:

点击下载

抖动另一种实现方式:

private Animation rotateAnimation() {
        Animation rotate = new RotateAnimation(-2.0f,
                                          2.0f,
                                          Animation.RELATIVE_TO_SELF,
                                          0.5f,
                                          Animation.RELATIVE_TO_SELF,
                                          0.5f);

         rotate.setRepeatMode(Animation.REVERSE);
        rotate.setRepeatCount(Animation.INFINITE);
        rotate.setDuration(60);
        rotate.setInterpolator(new AccelerateDecelerateInterpolator());

        return rotate;
    }

开始抖动:

view.startAnimation(rotateAnimation);

停止抖动:

view.clearAnimation();
原文地址:https://www.cnblogs.com/owner/p/3903125.html