간단히 화면을 클릭하면 보이고 다시 클릭하면 보이지 않는 동작을 만들고 싶습니다.
A라는 커스텀 뷰 안에 Top, Mid, Bottom 레이아웃이 포함되어있는 구조입니다.
안되는 소스::
public void show(){
topLayout.clearAnimation();
ctrlLayout.clearAnimation();
bottomLayout.clearAnimation();
topLayout.startAnimation(showTopAni);
ctrlLayout.startAnimation(showMidAni);
bottomLayout.startAnimation(showBtmAni);
topLayout.setVisibility(VISIBLE);
ctrlLayout.setVisibility(VISIBLE);
bottomLayout.setVisibility(VISIBLE);
}
public void hide(){
topLayout.clearAnimation();
ctrlLayout.clearAnimation();
bottomLayout.clearAnimation();
topLayout.startAnimation(hideTopAni);
ctrlLayout.startAnimation(hideMidAni);
bottomLayout.startAnimation(hideBtmAni);
topLayout.setVisibility(GONE);
ctrlLayout.setVisibility(GONE);
bottomLayout.setVisibility(GONE);
}
A를 단독으로 하나의 애니메이션과 visible속성을 변경하면 잘됩니다.
T,M,B에 각각 애니메이션을 주고 A의 visible를 조정하면 안됩니다.
많은 조언부탁드립니다. ㅠㅠ.. 하루종일 삽질을 했더니 혼란만 가중되는 것 같아요.
제가 모르는 view의 속성이나 animation의 특징같은게 있으면 던져주세요
이미 해결하셨겠지만 다음 분들을 위해 적자면
에니메이션이 끝난 시점에서 또 보입니다. 리스너를 만들어서 해야합니다.
AlphaAnimation ani = new AlphaAnimation(1, 0); //fade-out
ani.setDuration(700);
ani.setAnimationListener(test);
xxxxx.setAnimation(ani);
xxxxx.startAnimation(ani);
Animation.AnimationListener test= new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
xxxxxxxxxxxxxxxx.setVisibility(View.INVISIBLE);
}
};
애니메이션 동작 후에 clearAnimation을 해줘야지만 visible속성이 제대로 적용 되는거 같던데요
저도 비슷한 문제로 고민하다가 애니메이션이 끝난 시점에 혹은 비저블이 되야 하는 시점 바로 전에 clearAnimation해주니까 작동 하더라구요