Android 动画

Animation

Posted by LXG on August 26, 2020

Android-Animation-Set-Github

Activity动画的设置过程-简书

动画

  1. Window 动画
  2. 过渡动画
  3. View 动画

窗口动画

在Android系统中,窗口动画的本质就是对原始窗口施加一个变换(Transformation)。 在线性数学中,对物体的形状进行变换是通过乘以一个矩阵(Matrix)来实现,目的就是对物体进行偏移、旋转、缩放、切变、反射和投影等。 因此,给窗口设置动画实际上就给窗口设置一个变换矩阵(Transformation Matrix)。

窗口动画类型


public interface WindowManager extends ViewManager {

    /**
     * Not set up for a transition.
     * @hide
     */
    int TRANSIT_UNSET = -1;

    /**
     * No animation for transition.
     * @hide
     */
    int TRANSIT_NONE = 0;   // 无过渡动画

    /**
     * A window in a new activity is being opened on top of an existing one in the same task.
     * @hide
     */
    int TRANSIT_ACTIVITY_OPEN = 6; // 在同一task中在最顶端打开一个窗口

    /**
     * The window in the top-most activity is being closed to reveal the previous activity in the
     * same task.
     * @hide
     */
    int TRANSIT_ACTIVITY_CLOSE = 7; // 关闭当前活动窗口,恢复同一个task中的上一个窗口

    /**
     * A window in a new task is being opened on top of an existing one in another activity's task.
     * @hide
     */
    int TRANSIT_TASK_OPEN = 8;     // 新建任务并创建窗口

    /**
     * A window in the top-most activity is being closed to reveal the previous activity in a
     * different task.
     * @hide
     */
    int TRANSIT_TASK_CLOSE = 9;    // 关闭当前活动窗口,回到上一个任务

    /**
     * A window in an existing task is being displayed on top of an existing one in another
     * activity's task.
     * @hide
     */
    int TRANSIT_TASK_TO_FRONT = 10;  // 将任务移至最顶

    /**
     * A window in an existing task is being put below all other tasks.
     * @hide
     */
    int TRANSIT_TASK_TO_BACK = 11;    // 将当前任务移至最末

    /**
     * A window in a new activity that doesn't have a wallpaper is being opened on top of one that
     * does, effectively closing the wallpaper.
     * @hide
     */
    int TRANSIT_WALLPAPER_CLOSE = 12;  // 关闭壁纸应用

    /**
     * A window in a new activity that does have a wallpaper is being opened on one that didn't,
     * effectively opening the wallpaper.
     * @hide
     */
    int TRANSIT_WALLPAPER_OPEN = 13;         // 启动壁纸应用

    /**
     * A window in a new activity is being opened on top of an existing one, and both are on top
     * of the wallpaper.
     * @hide
     */
    int TRANSIT_WALLPAPER_INTRA_OPEN = 14;   // 有壁纸打开

    /**
     * The window in the top-most activity is being closed to reveal the previous activity, and
     * both are on top of the wallpaper.
     * @hide
     */
    int TRANSIT_WALLPAPER_INTRA_CLOSE = 15; // 有壁纸关闭

    /**
     * A window in a new task is being opened behind an existing one in another activity's task.
     * The new window will show briefly and then be gone.
     * @hide
     */
    int TRANSIT_TASK_OPEN_BEHIND = 16;

    /**
     * A window in a task is being animated in-place.
     * @hide
     */
    int TRANSIT_TASK_IN_PLACE = 17;

    /**
     * An activity is being relaunched (e.g. due to configuration change).
     * @hide
     */
    int TRANSIT_ACTIVITY_RELAUNCH = 18;   // Activity 重新加载

    /**
     * A task is being docked from recents.
     * @hide
     */
    int TRANSIT_DOCK_TASK_FROM_RECENTS = 19;

    /**
     * Keyguard is going away.
     * @hide
     */
    int TRANSIT_KEYGUARD_GOING_AWAY = 20;

    /**
     * Keyguard is going away with showing an activity behind that requests wallpaper.
     * @hide
     */
    int TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER = 21;

    /**
     * Keyguard is being occluded.
     * @hide
     */
    int TRANSIT_KEYGUARD_OCCLUDE = 22;

    /**
     * Keyguard is being unoccluded.
     * @hide
     */
    int TRANSIT_KEYGUARD_UNOCCLUDE = 23;

    /**
     * A translucent activity is being opened.
     * @hide
     */
    int TRANSIT_TRANSLUCENT_ACTIVITY_OPEN = 24;

    /**
     * A translucent activity is being closed.
     * @hide
     */
    int TRANSIT_TRANSLUCENT_ACTIVITY_CLOSE = 25;

    /**
     * A crashing activity is being closed.
     * @hide
     */
    int TRANSIT_CRASHING_ACTIVITY_CLOSE = 26;

}