I am using an AdaptorViewFlipper.
Its methods setInAnimation()
and setOutAnimation()
expect the resource ID of a XML with an ObjectAnimator
.
I want the animation to scale & fade the view simultaneously.
I define this scale_in_animator.xml
(for the sake of example I only post the In animation, the Out one is just the inverse)
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:propertyName="transitionScaleIn"
android:valueFrom="0"
android:valueTo="1"
android:valueType="floatType" />
And the view returned by the AdaptorViewFlipper
's adapter includes this function:
public void setTransitionScaleIn(float value) {
setScaleX(2-value);
setScaleY(2-value);
setAlpha(value);
}
However, nothing happens. setTransitionScaleIn
is not ever called.
Am I doing something wrong?
From AdapterViewFlipper
's source code:
.
.
// We wrap the new view in a FrameLayout so as to respect the contract
// with the adapter, that is, that we don't modify this view directly
FrameLayout fl = getFrameForChild();
.
.
So AdapterViewFlipper
wraps each children view inside a FrameLayout
, so I just had to extend AdapterViewFlipper and override this function:
FrameLayout getFrameForChild() {
return new FrameLayoutAnimable(getContext());
}
and of course create the class FrameLayoutAnimable
extending FrameLayout
with all the setXXXXX methods.
NOTE-> getFrameForChild
is a package method, so your extended AdapterViewFlipper
has to be in android.widget
package.