Android 之简单Tween动画设计


此次更新内容为Android老帖了——Tween动画。

Tween动画是指通过对场景里的对象不断进行图像变换来产生的动画效果。比如:平移,缩放,旋转等效果。与之相对应的是Frame动画,即是顺序播放事先准备好的图像,类似做电影。

Tween动画通过对View的内容完成一系列的图像变化来实现效果(包括平移,缩放,旋转,改变透明度)。主要包括以下4种动画效果:

  1. Scale: 尺寸伸缩动画效果
  2. Translate: 位置移动动画效果
  3. Rotate: 画面旋转动画效果
  4. Alpha: 透明度渐变动画效果

在这里,我选择第一个效果做事例。
我要做的效果是,当点击了桌面按钮后,他自身会消失,同时把隐藏的View01布局通过一个拉伸动画效果显示出来,4个按钮,做具体的按钮操作。再过5秒钟后,自动恢复到进入程序开始的状态。按钮重现,View01布局消失。

首先看一下布局的main.xml。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <AbsoluteLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_y="320px"
    android:layout_x="200px">
    <Button
    android:id="@+id/btn"
    android:text=" "
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
    </AbsoluteLayout>
    <AbsoluteLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_y="320px">
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/View01"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:visibility="invisible"
        >
            <Button
            android:id="@+id/Button01"
            android:text="test"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
            <Button
            android:id="@+id/Button02"
            android:text="test"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
            <Button
            android:id="@+id/Button03"
            android:text="test"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
            <Button
            android:id="@+id/Button04"
            android:text="test"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        </LinearLayout>
    </AbsoluteLayout>
</LinearLayout>

  • 1
  • 2
  • 下一页

相关内容