ANDROID30 Q Slide Assembly

Source: Internet
Author: User

This article comes from http://blog.csdn.net/w324821962, citing trouble to indicate the source

    为了让大家有个概念,这里引用了一下网络上的一个全景照片,相信大家对于这样的拍照技巧还是有了解过的,别说你没用过全景。


Now let's explain a few objects:

    • Lens
    • Scene
    • Content

So after the conversion, the picture should look like this.

The so-called lens is our phone screen size, whether it is 3.7 inch, 4.3 inch and so on.
The so-called scene is the orderly arrangement of all our content, whether it is landscape (viewpage), Portrait (ListView), etc.
The so-called content is what is displayed within the lens.
According to relativity, although we are actually moving the lens to capture the content to achieve the scene. In turn, the camera is stationary and we move the scene to show the content.

Provides a scroll class for swiping in Android
If you use Scroller, the process is as follows:

1. You can initialize the Scroller constructor as required in a custom layout.

2. Rewrite the onintercepttouchevent (motionevent ev) method to see if you want to intercept the associated click Time.

3. Rewrite the Ontouchevent (Motionevent event) method to use the Computescroll () and ScrollTo and Scrollby methods to slide the layout according to the finger based on the action on the touchscreen.

4. At the end of the touch operation (MOTIONEVENT.ACTION_UP), call startscroll (int startX, int starty, int dx, int dy, int duration) method, Animate automatically, To complete the rolling process.

The application for scroll is as follows

And the difference between ScrollTo and Scrollby is your understanding of to and by, ScrollTo is to that position, Scrollby is through this position.

On Android for gestures through a velocitytracker class. The Android.View.VelocityTracker is primarily used to track the rate of touch-screen events (flinging and other gestures events).
The general use is this:
Use the obtain () method to get an instance object of the Velocitytracker class when you need to track the speed of the touch screen event
In the ontouchevent callback function, use the addmovement (motionevent) function to pass the current move event to the Velocitytracker object
Use the computecurrentvelocity (int units) function to calculate the current speed, using the getxvelocity (), getyvelocity () function to get the current speed

private  velocitytracker mvelocitytracker;//in Ontouchevent (motionevent event)  if  (Mvelocitytracker = = null ) {mvelocitytracker = new  velocitytracker. Obtain (); //get Velocitytracker class instance } Mvelocitytracker. Addmotionevent (event ); //adds the event to the Velocitytracker class instance  //determine when EV event is motionevent.action_up: Calculation rate  final Velocitytracker Velocitytracker = Mvelocitytracker;velocitytracker.computercurrentvelocity (1 , ( float ) 0.01 ); Velocitytracker.computecurrentvelocity (1000 ); //set the value of units to 1000, meaning how many pixels are moving in a second time  

Through these days of study, the current understanding of sliding only so much, if this article to everyone has a little help, that my study is still a little fruitful.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

ANDROID30 Q Slide Assembly

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.