0
작은 질문은 TranslateAnimation을 사용한 후 안드로이드에서 취한 위치를 어떻게 얻습니까?애니메이션이 끝난 후 레이아웃의 새로운 위치를 얻으십시오.
사용자가 이미지를 터치하면 위로 이동하고 입력 화면을 표시합니다. 그러나 이미지가 최종 위치에 도달하면 이미지를 새 위치에 붙이고 싶습니다. 하지만 getHeight 또는 getLayoutParams를 사용할 때는 항상 이전 위치를 얻습니다. 이미지의 새로운 위치를 얻으려고 애니메이션 후
@Override
public void onAnimationEnd(Animation animation) {
product_buttons.requestLayout();
}
:
public void moveProducts() {
float addAmmountY = -250;
TranslateAnimation anim = new TranslateAnimation(0,0,0,addAmmountY); //(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta)
anim.setDuration(1000);
final LinearLayout product_buttons = (LinearLayout)findViewById(R.id.product_buttons);
anim.setAnimationListener(new TranslateAnimation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
//TODO set new location of the linearlayout
}
});
product_buttons.startAnimation(anim);
}