-
-
Save gejiaheng/8d34469298cadfb061cfed074127a7ee to your computer and use it in GitHub Desktop.
Up down animation for dialog fragment
This file contains hidden or 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
// Slide up animation | |
<?xml version="1.0" encoding="utf-8"?> | |
<translate xmlns:android="http://schemas.android.com/apk/res/android" | |
android:duration="@android:integer/config_mediumAnimTime" | |
android:fromYDelta="150%" | |
android:interpolator="@android:anim/accelerate_decelerate_interpolator" | |
android:toYDelta="0" /> | |
// Slide dowm animation | |
<?xml version="1.0" encoding="utf-8"?> | |
<translate xmlns:android="http://schemas.android.com/apk/res/android" | |
android:duration="@android:integer/config_mediumAnimTime" | |
android:fromYDelta="0" | |
android:interpolator="@android:anim/accelerate_interpolator" | |
android:toYDelta="150%" /> | |
// Style | |
<style name="DialogAnimation"> | |
<item name="android:windowEnterAnimation">@anim/slide_up</item> | |
<item name="android:windowExitAnimation">@anim/slide_down</item> | |
</style> | |
// Inside Dialog Fragment | |
@Override | |
public void onActivityCreated(Bundle arg0) { | |
super.onActivityCreated(arg0); | |
getDialog().getWindow() | |
.getAttributes().windowAnimations = R.style.DialogAnimation; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment