xml DialogFragment进入/退出动画

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml DialogFragment进入/退出动画相关的知识,希望对你有一定的参考价值。

// 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
}
<?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" />
<?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" />
<?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>

以上是关于xml DialogFragment进入/退出动画的主要内容,如果未能解决你的问题,请参考以下文章

显示 DialogFragment 动画从一个点开始

DialogFragment:如何防止一次又一次的动画?例如后台后

React 组件进入和退出动画实现

Activity打开退出动画:从底部向上打开,退出时从上至下退出,避免Activity退出时屏幕短暂黑屏

dotnet OpenXML 读取 PPT 主序列进入退出强调动画

dotnet OpenXML 读取 PPT 动画进入退出强调动画类型