Android Animation principle-Basic (Understanding view)

Source: Internet
Author: User

First, what is the animation

Animation is a dynamic medium in which images or objects be manipulated to appear as moving images. -From Wikipedia

Translation: Animation is a dynamic picture.

Second, the animation in Android

The screen of the phone is refreshed, normally at 60fps. That is, the 16ms interface will be refreshed once.

All of Android's animations are based on the 16ms, changing the area of the display to achieve the animation effect.

Because Android visual controls are drawn on the view, understanding the view is a great help in understanding animations.

Outline the drawing process of view

The drawing process of view is divided into three steps, measuring, layout, drawing.

These three words are easy to understand, and the following emphasis explains how these three steps relate specifically to view.

1. Measurement:
The measurement of the view takes place in measure, and the parent layout calls the Child.measure method to measure the child view. The appropriate feedback for sub-view should be to set your own size by setmeasuredimension method after measurement so that the parent view can be used as a reference.

The process of view measurement often occurs in the Onmeasure method, and the call Setmeasuredimension is actually set the view mmeasurewidth and mmeasureheight when the measurement is complete.

2. Layout:

The layout of the view takes place within layout, and the same parent layout calls Child.layout (l,r,t,b) and passes it to the child's set position for the child to set its own mleft,mright,mtop,mbottom.

The general situation will be directly based on the layout of the recommendations to set their own mleft,mright,mtop,mbottom.

Of course you can ignore the suggestion, set yourself, and note that if you change the mleft,mtop, it means that you are not satisfied with the top left corner of the parent view that you set.

If you change (mright-mleft) and (mbottom-mtop) means you are not satisfied with the size of the parent view that you set. -You should already know that the GETWIDHT and getheight of the view are the result of the first two subtraction operations obtained.

You can change them at any time while the program is running, and this scenario includes animations.

3. Draw

Draws the view that occurs in the draw method. The parent view will call this method of child's draw (x,x,x) three parameters through Drawchild, where one of the parameters is canvas.

In the Draw (X,x,x) method, the view defaults to canvas translate to the view's coordinate system, and then the hardware or software is drawn.

Android Animation principle-Basic (Understanding view)

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.