Skip to content

Instantly share code, notes, and snippets.

@gabornovakp
Created February 3, 2017 13:35
Show Gist options
  • Save gabornovakp/7760571b766dfd16b91eeea24d934ffc to your computer and use it in GitHub Desktop.
Save gabornovakp/7760571b766dfd16b91eeea24d934ffc to your computer and use it in GitHub Desktop.
Basic AlertDialog animation
public class AlertDialogHelper {
public static void showMyDialog(final Context context) {
final AlertDialog dialog = new AlertDialog.Builder(context)
.setTitle("My dialog")
.setMessage("This is your dialog, where you explain why the user needs to press the \"yes\" here.")
.setNeutralButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
//...
}
}).create();
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface d) {
View view = dialog.getWindow().getDecorView();
if (view != null) {
view.setScaleX(0f);
view.setScaleY(0f);
view.animate().scaleX(1f).scaleY(1f).setInterpolator(new FastOutSlowInInterpolator()).setDuration(300).start();
}
}
});
dialog.show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment