【问题标题】:How can I reduce the entry and exit animation speed of BottomSheetDialogFragment?如何降低 BottomSheetDialogFragment 的进出动画速度?
【发布时间】:2016-08-20 10:01:22
【问题描述】:

我不确定这是否可以使用 setEnterTransition()setExitTransition() 方法来实现。

【问题讨论】:

    标签: android material-design bottom-sheet


    【解决方案1】:

    我使用 StyleAnimation 解决了

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        if (getDialog() != null && getDialog().getWindow() != null)
            getDialog().getWindow().getAttributes().windowAnimations = R.style.DialogAnimation;
    }
    

    slide_in.xml

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:fromYDelta="100%p"
        android:toYDelta="0"
        android:duration="3000"/> <!--Define duration here-->
    </set>
    

    slide_out.xml

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:fromYDelta="0"
        android:toYDelta="100%p"
        android:duration="5000"/> <!--Define duration here-->
    </set>
    

    【讨论】:

      【解决方案2】:

      我想我得到了答案:

      我可以使用getDialog().getWindow().setWindowAnimations() 方法来实现。

      【讨论】:

      • 如果你在这里展示你的例子会更好。
      猜你喜欢
      • 2020-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-28
      • 2011-09-17
      • 1970-01-01
      • 2022-08-06
      • 1970-01-01
      相关资源
      最近更新 更多