Android Official Development Document Training Series Course Chinese version: Animation view of the transition frame introduction

Source: Internet
Author: User

Original address: http://android.xsoftlab.net/training/transitions/index.html

Introduction

The UI that the activity renders is often changed by the user's input or other events. For example, an activity with an input box will hide the input box after the user enters the keyword to be searched, and will show the results after the search in the input box.

In order to be able to present a consistent visual effect in this case, you can use animations in different view display and hide processes. These animations can provide users with a feedback and help them learn how the app is flowing.

Android provides this transition framework, which makes it easy for developers to convert between two view animations. This framework is animated by changing the properties of the view. The framework provides some common animation effects, and also allows developers to create custom animation effects and lifecycle callbacks during animation.

This lesson will learn how to use the built-in animation effect to effect two view. This lesson also includes knowledge of how to create custom animations.

Note: after Android 4.0, in the previous version of Android 4.4.2, use the Animatelayoutchanges property to make the animation function layout. For more information, see Property Animation and animating Layout changes.

Transition frame

Animation can provide more than just visual effects, it is more important to highlight the change, and provide some behavior to let the user subconsciously learn how the program works. Our most common example is the animation of the activity at the time of switching, and the normal toggle animation lets the user know whether to enter a page or exit a page.

To help developers learn about the animation between the view, Android provides a transition frame. This framework can work with one or a group of animations when the view changes.

The transition framework has the following features:

    • Group-level animations: A set of animation effects can be played at the same time.
    • transition-based Animation: The animation runs on the basis of the value change between the value of the View property from the beginning to the end.
    • Built-in animations: Provides built-in animations for common effects, such as fade in, fade out, or pan.
    • Resource file Support: Loads the view level and built-in animations from the layout resource file.
    • Lifecycle Callbacks: Defining callbacks provides finer control over the process of animating.
Overview

The Transition frame can act on any view. This view can be a single View object, or it can be a composite view container, such as ViewGroup. The transition frame animates the view by changing its properties.

The transition frame works between the view level and the two parallel lines of the animation. The purpose of this framework is to store the state of the view hierarchy, then change these levels, and then animate them by storing and applying animation definitions.

Demonstrates the relationship between the view hierarchy and the frame object and animation:

The transition framework provides an abstraction of the scene, transformation, and transformation manager. These sections are described in detail in the following sections. If you want to use the frame, first create a scene for the view hierarchy. Next, create a transform effect on the view. In order to start a transition animation, you need to use a conversion manager to indicate the transition animation and end scene. This process is described in detail in the remainder of the lesson.

Scene

The scene preserves the state of the view hierarchy, including all view and its attribute values. A view level can be a simple view object or a compound ViewGroup object. Storing the state of the view in a scene allows these states to transition from one scene to another. The scene framework provides the scene class to represent a scenario.

The transition framework can create a scene from a layout resource file or create a scene from a ViewGroup object. Creating a scene in code is used in two places: one is to dynamically generate the view level or to modify the scene at run time.

In many cases, there is no need to specifically create a startup scenario. If a conversion is already in place, the transition frame will use the previous end scene as the starting scenario for the next transformation. If no transformations have been taken, the framework collects information about the view in the current state of the screen.

Scenes can also define their own behavior, which runs when the scene changes. For example, this feature can be used to clear the view settings after the scene transition is complete. In addition to the view level and its property values, the scene can store a reference to the parent layout of the view hierarchy. This root view is called scene root. Changing scenes and animations can cause scenes in scene root to occur.

To learn more about creating scenes, see Creating a scene.

Transition

In the transition frame, the animation creates a series of frames that describe each detail change in the view hierarchy from the start to the end of the scene. The information about the animation is present in an object named transition. If you want to run the animation, you need to use the Transitionmanager object. The transition frame transforms in two different scenes or transforms different states in the current scene.

The transition frame contains a series of built-in transitions, which are used primarily for general animation effects. For example, fade in and out, adjust view size. You can also use the APIs provided by the animation framework to define custom scenes to create unique animation effects. The transition frame also allows developers to integrate different animation effects into a collection that can contain built-in animation effects or custom animations.

The life cycle of a transition is very similar to the activity's life cycle, which represents each transition state during the animation execution. In important lifecycle states, the transition framework invokes these callback methods, which allows the developer to adjust the user interface in a timely manner while the transition is in progress.

For more information about transitions, see Applying a transition and creating Custom transitions.

Limitations of transitions

This section lists some of the known deficiencies of the transition framework:

    • Animations may not display properly on Surfaceview. Because Surfaceview objects are updated by non-UI threads, this update may not be consistent with other view animations.
    • When using animations on Textureview, some special transition types may not produce the desired effect.
    • Classes that inherit from Adapterview, such as the ListView, manage sub-view in a way that is incompatible with the transition framework. If the view action is animated on top of Adapterview, the device interface may be suspended.
    • If you want the resize animation to work on TextView, the text on the TextView is drawn to a new position before the animation is complete. To avoid this problem, do not animate the resized animation on the view that contains the text.

Android Official Development Document Training Series Course Chinese version: Animation view of the transition frame introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.