I have a LinearLayout View in my activity.
When I press back button I want LinearLayout's children to slide out.
I have the following code which doesn't do anything:
private void SlideOut()
{
LayoutAnimationController controller = AnimationUtils.loadLayoutAnimation(this, R.anim.layout_animation_row_slide_out);
Animation animation=controller.getAnimation();
animation.setFillAfter(true);
LinearLayout menuLayout =((LinearLayout)findViewById(R.id.menuLayout));
menuLayout.setLayoutAnimation(controller);
menuLayout.startLayoutAnimation();
}
@Override
public void onBackPressed(){
//super.onBackPressed();
SlideOut();
}
I have commented out super.OnBackPressed() to see if the animation starts, and it don't start.
Somebody with similar problems ?
check if SlideOut() is called in onBackPressed - i'm guessing your back press is being handled elsewhere - possibly by the virtual keyboard
try this.it may help you:
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if(keyCode==KeyEvent.KEYCODE_BACK){
SlideOut();
return true;
}else{
return false;
}
//return super.onKeyDown(keyCode, event);
}
can u just change the code here here :
private void SlideOut()
{
Animation controller = AnimationUtils.loadLayoutAnimation(this, R.anim.layout_animation_row_slide_out);
// Animation animation=controller.getAnimation();
animation.setFillAfter(true);
LinearLayout menuLayout =((LinearLayout)findViewById(R.id.menuLayout));
menuLayout.startAnimation(controller);
}
I think you might be exiting the activity before animation is finished. Try implementing Animation Listener