Created
February 3, 2017 13:35
-
-
Save gabornovakp/7760571b766dfd16b91eeea24d934ffc to your computer and use it in GitHub Desktop.
Basic AlertDialog animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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