Here's my problem :
I've got a ViewAnimator like :
<ViewAnimator
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/viewanimator">
<ViewStub
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/form_viewstub"
android:inflatedId="@+id/form_view"
android:layout="@layout/form_layout"/>
<ViewStub
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/history_viewstub"
android:inflatedId="@+id/history_view"
android:layout="@layout/history_layout"/>
<ViewStub
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/call_viewstub"
android:inflatedId="@+id/call_view"
android:layout="@layout/call_layout"/>
</ViewAnimator>
When I'm animating a viewstub that is after the current, there is no problem. The problem is that when I try to animate a viewstub before, I can't see the animation. Here's a concrete example :
When I try to animate id/history_viewstub with the following animation and id/call_viewstub is the current displayed layout I do not see anything (I imagine that the animation is played behin the current view)
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:interpolator="@android:anim/accelerate_interpolator"
android:fromXScale="0.0"
android:toXScale="1.0"
android:fromYScale="0.0"
android:toYScale="1.0"
android:pivotX="1.0"
android:pivotY="0.0"
android:fillAfter="true"
android:duration="600"/>
<translate
android:fromXDelta="100%"
android:toXDelta="0"
android:duration="600"/>
</set>
Anybody has already faced this problem ?
Is there a way to specify a z-index to the viewstubs like in web development ?
Edit
Using the ZAdjustment property doesn't correct the problem
It seems to me that you are not actually using the functionality of the
ViewAnimatorclass but rather just the inheritedFrameLayoutclass.To animate view transitions you need to set the
android:inAnimationandandroid:outAnimationproperties on theViewAnimatorand initiate the transitions from your code using eithersetDisplayedChild()orshowNext()andshowPrevious().