The elastic slide of the view

Source: Internet
Author: User

The elastic slide of the view

Realize the idea of elastic sliding: A large slide is divided into several small sliding and completed in a time period, the specific implementation of a number of ways, such as through Scroller, handler#postdelayed and Thread#sleep and so on.

First, the use of scroller

A typical use method

The implementation of the elastic slide: When the view is redrawn, the computescroll is called in the Draw method, and Computescroll goes to Scroller to get the current scrollx and scrolly, and then the Scrollto method for sliding And then calls the Postinvalidate method for a second redraw, which, like the first redraw, causes the Computescroll method to be called, and then continues to get the current scrollx and scrolly to Scroller. and slide to the new position through the Scrollto method, so repeat until the entire sliding process is over.

Second, through the animation

Third, the use of delay policy

1. Using handler

The Postdelayed method of 2.View

3. Using the thread's Sleep method

The elastic slide of the 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.