小智 21
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();
}
});
Run Code Online (Sandbox Code Playgroud)
这个动画没有任何深度,但也许你会喜欢它.
您还可以使用设置动画持续时间
oa1.setDuration(1000);
oa2.setDuration(1000);
Run Code Online (Sandbox Code Playgroud)
bwt*_*bwt 15
属性动画(不要与旧的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();
Run Code Online (Sandbox Code Playgroud)
您可以使用View.setCameraDistance()调整透视效果
归档时间: |
|
查看次数: |
10282 次 |
最近记录: |