Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android; setting in/out animations on AdapterViewFlipper: Unknown animator name translate

I have some very simple animations that work perfectly with a ViewFlipper, but if I try setting them on an AdapterViewFlipper in/out, I get a runtime error "Unknown animator name translate". In looking at the respective methods on each, it looks like ViewFlipper expects a ViewAnimation, and AdapterViewFlipper expects an AdapterViewAnimation. The api's are otherwise the same, and both build without error. Here's the xml for one of the animations:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shareInterpolator="false">

    <translate
    android:fromXDelta="0%" android:toXDelta="-100%"
    android:fromYDelta="0%" android:toYDelta="0%"
    android:duration="800"/>
</set>

and I set it on the flipper like:

vf.setOutAnimation(this, R.anim.out_to_left);

I can guess this might mean that I can't use translate, type, but then how would I accomplish the same animation? Lame...

like image 923
wkhatch Avatar asked Mar 20 '13 19:03

wkhatch


1 Answers

Found the answer here: https://stackoverflow.com/a/26197426/1534666

It appears that a ViewFlipperAdapter needs a objectAnimator, not a set.

Example left_in.xml, declared in animator folder

<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
            android:interpolator="@android:anim/accelerate_decelerate_interpolator"
            android:propertyName="x"
            android:valueType="floatType"
            android:valueFrom="-1500"
            android:valueTo="0"
            android:duration="600"/>
like image 129
PieterAelse Avatar answered Oct 05 '22 23:10

PieterAelse