我正在尝试使用视图翻转器为 2 个视图之间的过渡设置动画。似乎默认情况下,ViewFlipper 将 Out 动画按 Z 顺序放置在 In 动画之上。有没有办法让传入的动画显示在传出的动画上?
谢谢
我正在尝试使用视图翻转器为 2 个视图之间的过渡设置动画。似乎默认情况下,ViewFlipper 将 Out 动画按 Z 顺序放置在 In 动画之上。有没有办法让传入的动画显示在传出的动画上?
谢谢
您可以在 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>
有关更多信息,请查看以下问题:开发 Android 主屏幕