小编mar*_*888的帖子

如何通过ObjectAnimator旋转drawable?

像这样对待一个可绘制的工作:

if(mAlphaAnimation == null){
        mAlphaAnimation = ObjectAnimator.ofFloat(this, "alpha", 0.0f,1.0f).setDuration(TARGET_ANIM_ALPHA_DURATION);
        mAlphaAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
        mAlphaAnimation.setStartDelay(TARGET_ANIM_ALPHA_DELAY_BASE*power);
        mAlphaAnimation.setRepeatCount(ValueAnimator.INFINITE);
        mAlphaAnimation.setRepeatMode(ValueAnimator.REVERSE);
        mAlphaAnimation.addUpdateListener(this);
 }
Run Code Online (Sandbox Code Playgroud)

但是,如果我想像下面那样旋转一个抽屉,它就不起作用了.

private void createRotateAnim(float fromDegress,float toDegress,int duration){
    if(mRotateAnimation == null){
        mRotateAnimation = ObjectAnimator.ofFloat(this, "rotation",fromDegress,toDegress).setDuration(duration);
        mRotateAnimation.setStartDelay(100);
        mRotateAnimation.setInterpolator(new AccelerateInterpolator());
        mRotateAnimation.addUpdateListener(this);
    }
}
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮我解决这个问题,或者这是创建旋转可绘制动画的任何其他方法.

我很遗憾我的英语不好.

android rotation drawable objectanimator

18
推荐指数
2
解决办法
3万
查看次数

标签 统计

android ×1

drawable ×1

objectanimator ×1

rotation ×1