private void startAnim() {

TranslateAnimation translateAnimation = new TranslateAnimation(0, 100, 0, 100);

translateAnimation.setDuration(1000);

translateAnimation.setFillAfter(true);

iv_laucher.startAnimation(translateAnimation);

translateAnimation.setAnimationListener(new Animation.AnimationListener() {

@Override

public void onAnimationStart(Animation animation) {

}

@Override

public void onAnimationEnd(Animation animation) {

//清除动画

iv_laucher.clearAnimation();

LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) iv_laucher.getLayoutParams();

params.leftMargin = params.leftMargin + 100;

params.topMargin = params.topMargin + 100;

iv_laucher.setLayoutParams(params);

}

@Override

public void onAnimationRepeat(Animation animation) {

}

});

}

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐