[ACCEPTED]-Animate an AlertDialog's entrance and exit-android-dialogfragment
Accepted answer
Here is the working code using the reference 5 and code from the above.
// Declare a Builder.
AlertDialog.Builder builder = new AlertDialog.Builder(context);
// You can even inflate a layout to the AlertDialog.Builder, if looking to create a custom one.
// Add and fill all required builder methods, as per your need.
// Now create object of AlertDialog from the Builder.
final AlertDialog dialog = builder.create();
// Let's start with animation work. We just need to create a style and use it here as follows.
if (dialog.getWindow() != null)
dialog.getWindow().getAttributes().windowAnimations = R.style.SlidingDialogAnimation;
dialog.show();
Regarding Style, I 4 used the same style as used in question 3 (in styles.xml).
<style name="SlidingDialogAnimation">
<item name="android:windowEnterAnimation">@android:anim/slide_in_left</item>
<item name="android:windowExitAnimation">@android:anim/slide_out_right</item>
</style>
But you can use any other 2 custom files by placing an animation XML 1 file in the res/anim folder.
Thanks.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.