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

自作多情 提交于 2020-08-06 12:30:30

问题


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


回答1:


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"/>


来源:https://stackoverflow.com/questions/15532929/android-setting-in-out-animations-on-adapterviewflipper-unknown-animator-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!