采用Animation.AnimationListener,在onAnimationEnd的方法中改变当前视图利用LayoutParams的setMargins方法重新定位位置。
代码:
public void move() {
jqkjScroll.setEnabled(true);
Animation mTranslateAnimation = new TranslateAnimation(0, 0, 0,
-showheight);// 移动
mTranslateAnimation.setDuration(minute);
// mAnimationSet.setFillAfter(true);
// mTranslateAnimation.setFillAfter(true);
mTranslateAnimation
.setAnimationListener(new Animation.AnimationListener() {
public void onAnimationStart(Animation animation) {
if (isNoMenu == false) {
curent.setVisibility(View.GONE);
}
}
public void onAnimationEnd(Animation animation) {
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
contentLayout.getLayoutParams());
contentImg.setImageResource(R.drawable.open);
params.setMargins(0, endY - startY, 0, 0);
contentLayout.clearAnimation();
contentLayout.setLayoutParams(params);
jqkjScroll.scrollTo(0, 0);
isMoveORShowing = false;
}
public void onAnimationRepeat(Animation animation) {
}
});
contentLayout.startAnimation(mTranslateAnimation);
}
public void show() {
jqkjScroll.setEnabled(false);
Animation mTranslateAnimation = new TranslateAnimation(0, 0, 0,
showheight);// 移动
mTranslateAnimation.setDuration(minute);
mTranslateAnimation
.setAnimationListener(new Animation.AnimationListener() {
public void onAnimationStart(Animation animation) {
if (isNoMenu == false) {
curent.setVisibility(View.VISIBLE);
}
}
public void onAnimationEnd(Animation animation) {
contentImg.setImageResource(R.drawable.close);
isMoveORShowing = false;
contentLayout.clearAnimation();
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
contentLayout.getLayoutParams());
params.setMargins(0, showheight + endY - startY, 0, 0);
contentLayout.setLayoutParams(params);
}
public void onAnimationRepeat(Animation animation) {
}
});
contentLayout.startAnimation(mTranslateAnimation);
}
取消
评论