【问题标题】:Custom fragment transition with kotlin使用 kotlin 自定义片段转换
【发布时间】:2018-10-04 06:18:22
【问题描述】:

你知道如何使用 kotlin 将自定义过渡动画注入到下面的 replaceFragment() 方法吗?它是一个片段到片段的过渡

  private inline fun FragmentManager.inTransaction(func: FragmentTransaction.() -> FragmentTransaction) {
        beginTransaction().func().commit()
    }

    private fun addFragment(fragment: Fragment, frameId: Int) {
        supportFragmentManager.inTransaction { add(frameId, fragment) }
    }

    public fun replaceFragment(fragment: Fragment, frameId: Int) {
        supportFragmentManager
                .inTransaction { replace(frameId, fragment) 
    }

【问题讨论】:

    标签: android android-fragments kotlin kotlin-android-extensions kotlin-extension


    【解决方案1】:

    找到解决方案:

    private inline fun FragmentManager.inTransaction(func: FragmentTransaction.() -> FragmentTransaction) {
            beginTransaction()
                    .func()
                    .setCustomAnimations()
                    .commit()
        }
    

    【讨论】:

      猜你喜欢
      • 2022-01-14
      • 1970-01-01
      • 1970-01-01
      • 2011-03-18
      • 1970-01-01
      • 2018-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多