ViewAnimationUtils为例,如果没有进行版本判断会报错。因为这个只能在api21以上才能使用。
https://developer.android.com/reference/android/view/ViewAnimationUtils.html
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
int cx = mShowAnswer.getWidth()/2;
int cy = mShowAnswer.getHeight()/2;
float radius = mShowAnswer.getWidth();
Animator anim = ViewAnimationUtils.createCircularReveal(mShowAnswer,cx,cy,radius,0);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override
public void onAnimationEnd(Animator animator) {
super.onAnimationEnd(animator);
mShowAnswer.setVisibility(View.INVISIBLE);
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
anim.start();
}else{
mShowAnswer.setVisibility(View.INVISIBLE);
}