Android – Unknown scene name: translate exception – when starting activity with transition

Issue

I’m trying to set up the animation of the appearance of the activity, but when the activity starts, the exception “java.lang.RuntimeException: Unknown scene name: translate” is thrown.

Manifest:

<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 layout xml:

android:theme"@style/SlidingPanel"

Transition 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>

If it matters, I start the activity from the fragment like this:

private fun onCreateNewTask(){
        val intent  Intent(context, CreateTargetActivity::class.java)
        intent.putExtra("targetPosition",targetPosition)
        startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(activity).toBundle())
    }

Please tell me how I can fix this!

Solution

Your Transition XML is not a valid Transition – that’s a View Animation XML file, not a transition (you’d apply view animations via overridePendingTransition called after you call startActivity)

As per the 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 with the Gravity.START edge:

<?xml version"1.0" encoding"utf-8"?>
<slide
    xmlns:android"http://schemas.android.com/apk/res/android"
    android:duration"250"
    android:slideEdge"start">
</slide>

Answered By – ianhanniballake

Leave a Comment