PlayPanel
activity should close in the form of a sliding panel to MainActivity
when back button is pressed. However, there is no animation. PlayPanel
activity simply closes normally.
PlayPanel activity
public class PlayPanel extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_play_panel);
}
@Override
public void onBackPressed() {
Intent intent = new Intent(
PlayPanel.this,
MainActivity.class
);
startActivity(intent);
overridePendingTransition(
0,
R.anim.play_panel_close_background
);
}
// onCreateOptionsMenu goes here
// onOptionsItemSelected goes here
}
play_panel_close_background.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromYDelta="0%"
android:toYDelta="100%"
android:duration="600"
/>
</set>
the solution:
@Override
public void onBackPressed() {
super.onBackPressed();
//startActivity(new Intent(this, MainActivity.class));
overridePendingTransition(
0,
R.anim.play_panel_close_outgoing_activity
);
}