2017-06-17 33 views
0

有可能使不断变化的图像,直到它设置最终的形象。我想改变图像时,它的翻转动画android

我想改变它的翻转图像。 因此而翻转

private ImageView image; 
private void images() { 

    int[] ps={R.drawable.img1,R.drawable.img2}; 
    Random r = new Random(); 
    int n=r.nextInt(2); 
    image.setImageResource(ps[n]); 

    ObjectAnimator animation = ObjectAnimator.ofFloat(coin, "rotationY", 0f, 360f); 
    animation.setDuration(500); 
    animation.setInterpolator(new AccelerateDecelerateInterpolator()); 
    animation.start(); 
} 

回答

0

是你可以为做到这一点你应该使用翻转动画看起来光滑,你可以找到从Here 此代码res/animator创建XML文件,上面的链接帮助

比在java文件

ObjectAnimator anim = (ObjectAnimator) 
AnimatorInflater.loadAnimator(mContext, R.animator.[FILE NAME]); 

int[] ps={R.drawable.img1,R.drawable.img2}; 
Random r = new Random(); 
int n=r.nextInt(2); 
image.setImageResource(ps[n]); 

anim.setTarget(image); 
anim.setDuration(500); 
anim.start();