【发布时间】:2019-01-15 07:39:06
【问题描述】:
我在 values-21/styles.xml 中添加了片段转换,如下所示:
<item name="android:fragmentEnterTransition">@transition/window_enter</item>
<item name="android:fragmentExitTransition">@transition/window_exit</item>
<item name="android:fragmentReturnTransition">@transition/window_return</item>
<item name="android:fragmentReenterTransition">@transition/window_reenter</item>
transition/window_enter.xml:
<?xml version="1.0" encoding="utf-8"?>
<slide />
transition/window_exit:
<?xml version="1.0" encoding="utf-8"?>
<slide/>
transition/window_return:
<?xml version="1.0" encoding="utf-8"?>
<explode/>
transition/window_reenter:
<?xml version="1.0" encoding="utf-8"?>
<explode/>
我正在使用普通的片段事务添加片段。我在像fragment.setEnterTransition() 这样的片段代码中不应用对转换API 的调用,因为我希望在给定styles.xml 中定义的转换的情况下自动应用转换。我不知道出了什么问题。 Android documentation 对片段转换并没有说太多。
【问题讨论】:
-
为什么是 values-21/styles.xml,为什么不是 values/styles.xml?
-
@MadLeo 因为 API 21+ 支持转换 API。
-
可能是因为你使用了支持片段?
-
使用支持片段@Ufkoku有什么问题吗?
-
@codezombie 也许他们没有在 android: 命名空间中使用转换属性
标签: android android-fragments android-transitions