带有自定义窗口动画的 DialogFragment;如何将 AnimationListener 添加到 dialogfragment?

DialogFragment with custom windowAnimations; How do I add an AnimationListener to dialogfragment?

我想在新的 dialogfragment 中制作动画,动画完成后,我想再做一个快速显示动画来显示内容。

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) 
{
    final Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.getWindow().getAttributes().windowAnimations =     R.style.detailDialogAnimation;
    return dialog;
}

这就是我设置 window 动画的方式,但是,我现在需要一种方法来确定 R.style.detailDialogAnimation 中的动画何时完成。这些动画完成后,是否可以从片段中收到回调?

我试过覆盖 onShow 侦听器,但它似乎在动画开始之前被调用。

我找不到有关获取 window 动画回调的任何信息。

我最终为我的对话框根视图设置了一个 GlobalLayoutListener 并从那里调用动画。

rootView.getViewTreeObserver().addOnGlobalLayoutListener(...);