【问题标题】:Fragment transition with shared element similar to activity具有类似于活动的共享元素的片段转换
【发布时间】:2020-08-09 14:44:09
【问题描述】:

我想知道如何实现片段和导航组件文档提供的此类转换,例如(使用共享元素启动活动)

[https://developer.android.com/training/transitions/start-activity][1]

【问题讨论】:

    标签: android fragment transition


    【解决方案1】:

    Android 框架已经为片段提供了共享元素转换。您可以按照博客中提供的步骤开始使用它们:

    对于fragment,我们需要在执行fragment事务时指定共享的transition元素:

    getActivity().getSupportFragmentManager()
            .beginTransaction()
            .addSharedElement(holder.image, "sharedImage")
            .replace(R.id.container, details)
            .addToBackStack(null)
            .commit();
    

    希望这个答案对您有用。

    【讨论】:

    • 这不是我想要的,因为我使用的是喷气背包的导航组件
    • @Reham Alatris ,我认为您需要 Sergio Belda link.medium.com/ctmzefx6Z5 的“Android 导航组件中的转换”@
    猜你喜欢
    • 1970-01-01
    • 2015-09-03
    • 2018-07-30
    • 2015-08-06
    • 1970-01-01
    • 2015-01-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多