Android (Android) to achieve the principle of paging function analysis

Source: Internet
Author: User

Three kinds of page-flipping effects in the Android platform.

The first page-flipping effect is as follows:

Implementation principle:

the current finger touch point is a, the point a coordinates is (Ax,ay), the triangle ACB and the triangle CMB is the symmetric triangle and the line CP is AM Street, then the b point coordinate is (AX/2,AY/2).

GF perpendicular to the OM and CB perpendicular to AM, triangular cfg and GFM similar, then CF:GF = GF:MF cf= (GF * GF)/MF GF Length of G-point ordinate MF length of G-point Horizontal

CF length can be obtained by C-point coordinates can be determined by the C-point, G-point to determine the line between two points, when the line in the x=0 to find the point of the Y-foot intersection.

Second page effect

Implementation principle:

use Bezier curves. the curve has four points: the starting point, the endpoint (also known as the anchor Point), and the two mutually separated intermediate points. The shape of the Bezier curve changes as you slide two middle points.

According to the first page effect principle can determine a, E, H, F, g, by eh parallel to CJ and AF perpendicular to eh, then af perpendicular to CJ triangle EGF similar to triangular cnf have ef:cf = gf:nf.

where n is the midpoint of AG with cf= (3/2) *ef, then the C-point coordinate can be obtained by the C-point and K-point coordinates known as the line between two points

The line can be computed with the y-axis intersection point J by a, E, C, J can calculate the intersection point B of two lines can be the same point K.

Specific steps to implement in Android:

Start Page Show

1. Create a screen size of BMP 2. Converts the picture to Canvas 3. Gets the start Page Data 3. Draw Start Page data in Canvas 4. Make a copy of the OnDraw in the current view to redraw the BMP object

Flip page Processing

1. Create two BMP (BMP1, BMP2) at initialization and convert it to canvas (CANVAS1, CANVAS2)

2. Get the first touch of the gesture area (example: When the first click on the screen position x<50&&y<50 is the upper left corner)

3. According to the first click Region to determine the data to be displayed (example: first click on the left side of the area "upper left, lower left" of the decision operation for the next page operation)

4. Get the data from the next page and draw it out in the CANVAS2.

5. Call the start animation based on the location of the region obtained in 1 to move the view to the first click position of the gesture

6. Gets the coordinates of each movement of the gesture and calculates the coordinates of each point drawn according to the moving coordinates

7. Refresh view every time you move

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.