Skip to content

Instantly share code, notes, and snippets.

@nknr
Last active December 6, 2019 08:52
Show Gist options
  • Save nknr/391b993041d3a902b27040276c01ca00 to your computer and use it in GitHub Desktop.
Save nknr/391b993041d3a902b27040276c01ca00 to your computer and use it in GitHub Desktop.
private void showDialog(){
AlertDialog.Builder builder = new androidx.appcompat.app.AlertDialog.Builder(this);
builder.setTitle(R.string.exit);
builder.setMessage(R.string.exit_text);
builder.setPositiveButton(getResources().getString(R.string.yes), (dialog, arg1) -> finishAffinity());
builder .setNegativeButton(getResources().getString(R.string.no), (dialog, arg1) -> dialog.dismiss());
androidx.appcompat.app.AlertDialog dialog = builder.create();
dialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation_2;
dialog.show();
}
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromYDelta="0%p"
android:interpolator="@android:anim/accelerate_interpolator"
android:toXDelta="100%p"/>
</set>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromYDelta="100%"
android:interpolator="@android:anim/accelerate_interpolator"
android:toXDelta="0"/>
</set>
<style name="DialogAnimation_2">
<item name="android:windowEnterAnimation">@anim/slide_up</item>
<item name="android:windowExitAnimation">@anim/slide_bottom</item>
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment