Skip to content Skip to sidebar Skip to footer

How Can I Start Layoutanimation When(before) Leaving An Activity

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 S

Solution 1:

check if SlideOut() is called in onBackPressed - i'm guessing your back press is being handled elsewhere - possibly by the virtual keyboard

Solution 2:

try this.it may help you:

public boolean onKeyDown(int keyCode, KeyEvent event) {
    // TODO Auto-generated method stubif(keyCode==KeyEvent.KEYCODE_BACK){
    SlideOut();
    returntrue;
    }else{
        returnfalse;
    }

    //return super.onKeyDown(keyCode, event);

}

can u just change the code here here :

privatevoidSlideOut()
{
    Animationcontroller= AnimationUtils.loadLayoutAnimation(this, R.anim.layout_animation_row_slide_out);
   // Animation animation=controller.getAnimation();
    animation.setFillAfter(true);
    LinearLayoutmenuLayout=((LinearLayout)findViewById(R.id.menuLayout));
    menuLayout.startAnimation(controller);

}

Solution 3:

I think you might be exiting the activity before animation is finished. Try implementing Animation Listener

Post a Comment for "How Can I Start Layoutanimation When(before) Leaving An Activity"