Android Little Knowledge Point

Source: Internet
Author: User

Summary of small knowledge points

1.

How is the Motionevent.action_cancel event triggered in Android?

For this question, the description of the Android documentation is very brief and it is difficult to see it clearly. A foreign page said more detailed, written here to share to you:

This is the original:

You receive this if a parent takes possession of the motion, for example when the user has dragged enough across a list View or scroll view that it'll start scrolling instead of letting you press the buttons inside of it.

The meaning is this:

This event is triggered when your finger (or other) moves the screen, such as when your finger drags a ListView or a scrollview over the screen instead of pressing the button above.

2.

Computescroll: The main function is to calculate the amount of displacement to drag, update the background, set the screen to be displayed (Setcurrentscreen (mcurrentscreen);).

Reasons for overriding Computescroll ()

Call Startscroll () will not have scrolling effect, only in computescroll () get scrolling condition, make scrolling response

Computescroll This method is called when the parent control executes Drawchild

Scroller is not a view, it is not responsible for any display work, just calculates the scrolling process.
You can use Startscroll (int startX, int starty, int dx, int dy) to specify the starting position and the X/Y axis displacement.
Then call Computescrolloffset () to calculate the current position, return "true" for scrolling, and return "false" to represent the end of scrolling
Finally call Getcurrx ()/getcurry () to get the current coordinates and then draw your view based on this coordinate

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.