Reputation: 463
I am attempting to animate a part of an android app, unfortunately I can not get my animation to work correctly.
The following xml file works correctly, but it has an absolute reference rather than a relative one.
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:propertyName="x"
android:valueType="floatType"
android:valueTo="0"
android:valueFrom="100"
android:duration="800"
/>
When I try a a relative reference, like the following, the animation is not correct. It produces the correct screen, but the fragment just appears, rather than sliding in from the left.
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:propertyName="translationX"
android:fromXDelta="100%"
android:toXDelta="0%"
android:duration="500"/>
Does anyone have the solution to this?
Upvotes: 0
Views: 251
Reputation: 1237
Reverse your fromXdelta and toxDelta values. You are applying the 100% change at the start of the animation and 0% at the end.
From: http://developer.android.com/reference/android/view/animation/TranslateAnimation.html
fromXValue Change in X coordinate to apply at the start of the animation.
toXValue Change in X coordinate to apply at the end of the animation.
Upvotes: 1