Android使用FragNavTransactionOptions在片段之间进行简单转换

时间:2019-01-10 09:03:00

标签: android android-fragments

当我在项目中使用FragNav库时,我试图在片段之间进行简单的过渡,例如在主片段上,我使用了FragNavTransactionOptions到第二个片段

FragNavTransactionOptions.Builder transition = new FragNavTransactionOptions.Builder().addSharedElement(new Pair<>(view, transitionName));
fragmentNavigation.pushFragment(SampleFragment.createInstance(0), transition.build());

如何在SampleFragment.class片段上获取该片段,以使片段之间具有简单的过渡视图?

  

交易选项

     

以上所有交易也可以通过定义   交易选项。 FragNavTransactionOptions具有一个生成器   可以使用。

class FragNavTransactionOptions private constructor(builder: Builder)
    {
        val sharedElements: List<Pair<View, String>> = builder.sharedElements
        @FragNavController.Transit
        val transition = builder.transition

        @AnimRes
        val enterAnimation = builder.enterAnimation

        @AnimRes
        val exitAnimation = builder.exitAnimation

        @AnimRes
        val popEnterAnimation = builder.popEnterAnimation

        @AnimRes
        val popExitAnimation = builder.popExitAnimation

        @StyleRes
        val transitionStyle = builder.transitionStyle
        val breadCrumbTitle: String? = builder.breadCrumbTitle
        val breadCrumbShortTitle: String? = builder.breadCrumbShortTitle
        val allowStateLoss: Boolean = builder.allowStateLoss

0 个答案:

没有答案