【发布时间】:2011-10-20 15:19:42
【问题描述】:
这是我的问题:
我有一个像这样的 ViewAnimator:
<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>
当我为当前视图之后的视图设置动画时,没有问题。问题是,当我之前尝试为 viewtub 设置动画时,我看不到动画。这是一个具体的例子:
当我尝试使用以下动画为id/history_viewstub 设置动画并且id/call_viewstub 是当前显示的布局时,我什么都看不到(我想动画是在当前视图后面播放的)
<?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>
有人遇到过这个问题吗?
有没有办法像在 web 开发中一样为视图指定一个 z-index ?
编辑
使用ZAdjustment 属性并不能解决问题
【问题讨论】:
-
您在使用
showPrevious()和showNext()以及setInAnimation和setOutAnimation吗? -
不,我正在使用 setDisplayedChild(int index)
标签: android android-layout z-index android-animation viewanimator