【发布时间】:2011-06-16 03:50:09
【问题描述】:
我正在尝试使用视图翻转器为 2 个视图之间的过渡设置动画。看起来,默认情况下,ViewFlipper 将 Out 动画按 Z 顺序放置在 In 动画之上。有没有办法让传入的动画显示在传出的动画上?
谢谢
【问题讨论】:
标签: android animation viewflipper z-order
我正在尝试使用视图翻转器为 2 个视图之间的过渡设置动画。看起来,默认情况下,ViewFlipper 将 Out 动画按 Z 顺序放置在 In 动画之上。有没有办法让传入的动画显示在传出的动画上?
谢谢
【问题讨论】:
标签: android animation viewflipper z-order
您可以在 Android 启动器中找到此功能。由于 Android 是开源的,您可以直接复制和使用它。
使用名为 DragableSpace 的代码:http://pastebin.com/CgK8TCQS。在您的活动中,您调用:
setContentView(R.layout.main);
与:
<?xml version="1.0" encoding="utf-8"?>
<de.android.projects.DragableSpace
xmlns:app="http://schemas.android.com/apk/res/de.android.projects"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/space"
android:layout_width="fill_parent" android:layout_height="fill_parent"
app:default_screen="1">
<include android:id="@+id/left" layout="@layout/left_screen" />
<include android:id="@+id/center" layout="@layout/initial_screen" />
<include android:id="@+id/right" layout="@layout/right_screen" />
</de.android.projects.DragableSpace>
如您所见,您可以只使用 xml 为您的应用程序定义一个主屏幕;)
定义每个视图(初始、右和左) 像这样:
<LinearLayout android:id="@+id/center"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:background="@color/orange">
<Button android:text="Initial Screen" android:id="@+id/Button2"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:padding="10dp" android:layout_margin="10dp">
</Button>
</LinearLayout>
有关更多信息,请查看此问题:Developing an Android Homescreen
【讨论】: