I am trying to animate a transition between two fragments by fading the current to the left and fading in the new one from the right. The app crashes on runtime.
minSdkVersion: 16
targetSdkVersion: 23
emulator running on api version 23
Activity code
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.setCustomAnimations(R.animator.enter_from_right, R.animator.exit_to_left);
transaction.replace(R.id.listFragmentContainer, fragment);
transaction.commit();
res/animator/enter_from_right.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<ObjectAnimator
android:fromXDelta="100%" android:toXDelta="0%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="700"/>
</set>
res/animator/exit_to_left.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<ObjectAnimator
android:fromXDelta="0%" android:toXDelta="-100%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="700"/>
</set>
LogCat
02-17 12:00:25.028 16696-16696/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.eivind.ticktick, PID: 16696
java.lang.RuntimeException: Unknown animator name: ObjectAnimator
you just miss writing objectAnimator element
change ObjectAnimator to objectAnimator to be like this
res/animator/enter_from_right.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<objectAnimator
android:fromXDelta="100%" android:toXDelta="0%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="700"/>
</set>
res/animator/exit_to_left.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<objectAnimator
android:fromXDelta="0%" android:toXDelta="-100%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="700"/>
</set>