Skip to content

Instantly share code, notes, and snippets.

@zlq4863947
Last active March 20, 2018 09:19
Show Gist options
  • Save zlq4863947/4735eb1a0a64ddb4b49366283de4f3c7 to your computer and use it in GitHub Desktop.
Save zlq4863947/4735eb1a0a64ddb4b49366283de4f3c7 to your computer and use it in GitHub Desktop.
/**
* 动画移动view并摆放至相应的位置
*
* @param view 控件
*/
public static void moveViewWithAnimation(final View view) {
//创建位移动画
TranslateAnimation ani = new TranslateAnimation(view.getRight(), 0, 0, 0);
ani.setInterpolator(new AccelerateInterpolator());//设置加速器
ani.setDuration(400);//设置动画时间
ani.setStartOffset(0);//设置动画延迟时间
//监听动画播放状态
ani.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {}
@Override
public void onAnimationRepeat(Animation animation) {}
@Override
public void onAnimationEnd(Animation animation) {
view.clearAnimation();
}
});
view.startAnimation(ani);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment