Expected behavior:
- Dialog comes up from under the screen to about 80% on the bottom
- Dialog stays there for 3 seconds
- Dialog goes back under the screen
What's really happening:
- Dialog comes up from under the screen to about 80% on the bottom
- Dialog jumps to the top of the screen
- Dialog stays there for 3 seconds
- Dialog jumps back to about 80% bottom of the screen
- Dialog goes back under the screen
Why?
Slide up:
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="100%p"
android:toYDelta="75%p"
android:fillAfter="true"
android:duration="1000" />
Slide down:
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="75%p"
android:toYDelta="100%p"
android:fillAfter="true"
android:duration="1000" />
Style:
<style name="dialog_animation">
<item name="android:windowEnterAnimation">@anim/slide_up</item>
<item name="android:windowExitAnimation">@anim/slide_down</item>
</style>
Code:
dialog = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar);
dialog.setContentView(R.layout.toast_goal_added);
dialog.getWindow().getAttributes().windowAnimations = R.style.dialog_animation;
dialog.setCancelable(true);
Handler handler = null;
handler = new Handler();
handler.postDelayed(new Runnable(){
public void run(){
dialog.cancel();
dialog.dismiss();
}
}, 3500);
dialog.show();