我已经厌倦了在android中制作一张翻转卡。请拍一张图片,当我点击它时,它翻转就像
答案 0 :(得分:15)
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final ObjectAnimator oa1 = ObjectAnimator.ofFloat(imageView, "scaleX", 1f, 0f);
final ObjectAnimator oa2 = ObjectAnimator.ofFloat(imageView, "scaleX", 0f, 1f);
oa1.setInterpolator(new DecelerateInterpolator());
oa2.setInterpolator(new AccelerateDecelerateInterpolator());
oa1.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
imageView.setImageResource(R.drawable.frontSide);
oa2.start();
}
});
oa1.start();
}
});
这个动画没有任何深度,但也许你会喜欢它。
您还可以使用
设置动画持续时间oa1.setDuration(1000);
oa2.setDuration(1000);
答案 1 :(得分:9)
Property Animations(不要与较旧的View动画混淆)非常强大:
final View v = <the_image_view>;
// first quarter turn
v.animate().withLayer()
.rotationY(90)
.setDuration(300)
.withEndAction(
new Runnable() {
@Override public void run() {
<change the image...>
// second quarter turn
v.setRotationY(-90);
v.animate().withLayer()
.rotationY(0)
.setDuration(300)
.start();
}
}
).start();
调整透视效果