Android - 未知场景名称:翻译异常 - 开始 activity 时出现过渡
Android - Unknown scene name: translate exception - when starting activity with transition
我正在尝试设置 activity 出现的动画,但是当 activity 启动时,出现异常“java.lang.RuntimeException:未知场景名称:翻译”被抛出。
清单:
<activity android:name=".ui.createtarget.CreateTargetActivity" android:theme="@style/SlidingPanel"/>
Styles.xml:
<style name="SlidingPanel" parent="AppTheme">
<item name="android:windowEnterTransition">@transition/slide_from_bottom</item>
<item name="android:windowExitTransition">@transition/slide_to_bottom</item>
</style>
Activity布局xml:
android:theme="@style/SlidingPanel"
过渡xml:
<?xml version="1.0" encoding="utf-8"?>
<translate
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="250"
android:fromXDelta="-100%p"
android:toXDelta="0%p">
</translate>
如果重要的话,我从这样的片段开始 activity:
private fun onCreateNewTask(){
val intent = Intent(context, CreateTargetActivity::class.java)
intent.putExtra("targetPosition",targetPosition)
startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(activity).toBundle())
}
请告诉我如何解决这个问题!
您的转换 XML 不是有效的转换 - 这是在您调用 startActivity
)
之后调用的 View Animation XML file, not a transition (you'd apply view animations via overridePendingTransition
根据 Start an activity using a transition guide, you need to use one the types listed there. In your case, it looks like you should be using a Slide Transition 和 Gravity.START
边缘:
<?xml version="1.0" encoding="utf-8"?>
<slide
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="250"
android:slideEdge="start">
</slide>
我正在尝试设置 activity 出现的动画,但是当 activity 启动时,出现异常“java.lang.RuntimeException:未知场景名称:翻译”被抛出。
清单:
<activity android:name=".ui.createtarget.CreateTargetActivity" android:theme="@style/SlidingPanel"/>
Styles.xml:
<style name="SlidingPanel" parent="AppTheme">
<item name="android:windowEnterTransition">@transition/slide_from_bottom</item>
<item name="android:windowExitTransition">@transition/slide_to_bottom</item>
</style>
Activity布局xml:
android:theme="@style/SlidingPanel"
过渡xml:
<?xml version="1.0" encoding="utf-8"?>
<translate
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="250"
android:fromXDelta="-100%p"
android:toXDelta="0%p">
</translate>
如果重要的话,我从这样的片段开始 activity:
private fun onCreateNewTask(){
val intent = Intent(context, CreateTargetActivity::class.java)
intent.putExtra("targetPosition",targetPosition)
startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(activity).toBundle())
}
请告诉我如何解决这个问题!
您的转换 XML 不是有效的转换 - 这是在您调用 startActivity
)
overridePendingTransition
根据 Start an activity using a transition guide, you need to use one the types listed there. In your case, it looks like you should be using a Slide Transition 和 Gravity.START
边缘:
<?xml version="1.0" encoding="utf-8"?>
<slide
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="250"
android:slideEdge="start">
</slide>