直接上代码
使用:
直接把Dialog的ContentView 执行caDialogAnimation(view)即可
public static void caDialogAnimation(View view){
ObjectAnimator animatorX = ObjectAnimator.ofFloat(view,"scaleX",0.7f,1.0f);
ObjectAnimator animatorY = ObjectAnimator.ofFloat(view,"scaleY",0.7f,1.0f);
AnimatorSet set = new AnimatorSet();
set.setDuration(300);
set.setInterpolator(new SpringScalingInterpolator(0.4f));
set.playTogether(animatorX,animatorY);
set.start();
}
public static class SpringScalingInterpolator implements Interpolator {
//弹性因数
private float factor;
public SpringScalingInterpolator(float factor){
this.factor = factor;
}
@Override
public float getInterpolation(float input) {
return (float) (Math.pow(2, -10 * input) * Math.sin((input - factor / 4) * (2 * Math.PI) / factor) + 1);
}
}
暂无评论
要发表评论,您必须先 登录