Custom controls: The implementation of the Ferris wheel 1

Source: Internet
Author: User

The 1 Ferris wheel control can be rotated by touch, but the direction of the child view is maintained during the rotation.
2 Ferris wheel Control in the touch of rotation, the basis of inertia rotation is the placement of automatic control parts, using a triangular function to determine the sub-view
Center point Position, note that in the analysis phase we take the center point of the Ferris wheel as a reference point (0,0), when writing code, remember
Offset to the top left of the control.
3 in touch rotation and inertia rotation, we need to change the position of all children, in fact, the center point of the Child and
The angle of the center line, but because the angle interval is equal, it only needs to change the angle of the first child, and then the other child and the second
A child maintains an angle interval and then calls Requestlayout to rearrange the child.
4 touch rotation and inertia rotation, both use the Gesturedector to help us determine the type of touch event and
Supply the parameters that we need.
5 in touch rotation, by calculating the angle of the current point and the angle of the previous point, and then calculating the difference of two points, we can
To know how many angles need to be rotated.
6 The more difficult place is to convert the inertial sliding pixel speed into angular velocity, for students who have not studied calculus can
Can not imagine. We then used the value animation to constantly change the angle to simulate the rotation, and the deceleration interpolator was used to simulate deceleration.
7 because the touch event handling of the Ferris wheel is written in the Ontoucheven,t method, if the child control consumes the touch
The Ontoucheevent method of the Ferris wheel is not called, so we need to
The Onintercepttouchevent method returns ture, and then detects the Click event sent to the child who was clicked.

Custom controls: The implementation of the Ferris wheel 1

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.