【问题标题】:some view in fragment not animated with transition片段中的某些视图未使用过渡动画
【发布时间】:2023-03-18 08:31:01
【问题描述】:

我想通过 setEnterTransition 方法实现一个 Fragment 切换动画。

片段视图是这样的:

    <RelativeLayout
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:gravity="center_horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/id_rl_root">

    <View
        android:id="@+id/view_stub_animation"
        android:layout_width="match_parent"
        android:background="#ccffee"
        android:layout_height="30dp">
    </View>
    <FrameLayout
        android:layout_marginTop="30dp"
        android:id="@+id/index_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    </FrameLayout>
</RelativeLayout>

索引容器中的视图是动态生成的。和这样的页面

我在 BaseFragment.onCreate 方法中添加 enterTransition。

    val inflater = TransitionInflater.from(requireContext())
    enterTransition = inflater.inflateTransition(R.transition.slide_right)

当我进入片段时,只有 view_stub_animation 做动画,而 index_container 直接出来。

我不想使用 setCustomAnimate,因为当我做动画时,页面呈现不够流畅。

疯了。提前谢谢你

【问题讨论】:

    标签: android kotlin android-fragments


    【解决方案1】:

    最后,我意识到,如果我给 Index_Container 添加背景颜色,我可以为它设置动画,这感觉像是一个过渡功能?也许……

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-23
      • 2023-02-05
      相关资源
      最近更新 更多