一个按钮,两个TextView(布局文件在源码部分)
final TextView visibletext;
final TextView invisibletext;
//逻辑判断
if (textview1.getVisibility() == View.GONE) {
visibletext = textview2;
invisibletext = textview1;
} else {
invisibletext = textview2;
visibletext = textview1;
}
//LinearInterpolator() 其变化速率恒定
ObjectAnimator visToInvis = ObjectAnimator.ofFloat(visibletext, “rotationY”, 0f, 90f);
visToInvis.setDuration(500);
//AccelerateInterpolator() 其变化开始速率较慢,后面加速
visToInvis.setInterpolator(new AccelerateInterpolator());
final ObjectAnimator invisToVis = ObjectAnimator.ofFloat(invisibletext, “rotationY”,
-90f, 0f);
invisToVis.setDuration(500);
//DecelerateInterpolator() 其变化开始速率较快,后面减速
invisToVis.setInterpolator(new DecelerateInterpolator());
visToInvis.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator anim) {
visibletext.setVisibility(View.GONE);
invisToVis.start();
invisibletext.setVisibility(View.VISIBLE);
}
});