I want to implement slide up & down animation when an activity is pushed to / off stack. Here is my code:
public class LoginActivity extends ActionBarActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
overridePendingTransition(R.anim.slide_up, R.anim.nothing);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
Button loginBtn = (Button)findViewById(R.id.login);
loginBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
@Override
public void onBackPressed() {
finish();
}
@Override
public void finish() {
overridePendingTransition(R.anim.nothing, R.anim.slide_down);
super.finish();
}
}
The activity is started via "startActivityForResult()) method. The theme for this activity is "Theme.AppCompat.Light.NoActionBar".
Here is the problem:
The animation for launching activity works.
When pressed "back" button, the slide-down animation also works.
However, when I call "finish()" directly within the activity to close it, the animation does notwork.
What's the problem? How to fix it?