Created
October 5, 2014 00:26
-
-
Save jasco/e757f1011bb0e62d365f to your computer and use it in GitHub Desktop.
DialogFragment enter/exit animations
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
// example courtesy of http://adilatwork.blogspot.com/2012/11/android-dialogfragment-enter-and-exit.html | |
// file location: src/main/java/com/example/ | |
@Override | |
public void onStart() { | |
super.onStart(); | |
// safety check | |
if (getDialog() == null) { | |
return; | |
} | |
// set the animations to use on showing and hiding the dialog | |
getDialog().getWindow().setWindowAnimations( | |
R.style.dialog_animation_fade); | |
// alternative way of doing it | |
//getDialog().getWindow().getAttributes(). | |
// windowAnimations = R.style.dialog_animation_fade; | |
// ... other stuff you want to do in your onStart() method | |
} |
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
<?xml version="1.0" encoding="utf-8"?> | |
<!-- | |
courtesy of http://adilatwork.blogspot.com/2012/11/android-dialogfragment-enter-and-exit.html | |
file location: src/main/res/anim | |
--> | |
<alpha | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:interpolator="@android:anim/accelerate_interpolator" | |
android:fromAlpha="0.0" | |
android:toAlpha="1.0" | |
android:duration="400" /> |
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
<?xml version="1.0" encoding="utf-8"?> | |
<!-- | |
courtesy of http://adilatwork.blogspot.com/2012/11/android-dialogfragment-enter-and-exit.html | |
file location: src/main/res/anim | |
--> | |
<alpha | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:interpolator="@android:anim/decelerate_interpolator" | |
android:fromAlpha="1.0" | |
android:toAlpha="0.0" | |
android:duration="400" /> |
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
<?xml version="1.0" encoding="utf-8"?> | |
<!-- | |
courtesy of http://adilatwork.blogspot.com/2012/11/android-dialogfragment-enter-and-exit.html | |
file location: src/main/res/values | |
--> | |
<style | |
name="dialog_animation_fade" > | |
<item name="android:windowEnterAnimation">@anim/fade_in_dialog</item> | |
<item name="android:windowExitAnimation">@anim/fade_out_dialog</item> | |
</style> |
Thanks. It works great.
It simple and works great! thanks!
It works great
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks bro.