Android 30 slide Components

Source: Internet
Author: User

Android 30 slide Components

This article is from http://blog.csdn.net/w324821962.

In order to let everyone have a concept, here we reference a panoramic photo on the network. I believe you have learned about this kind of photo taking technique, not to mention that you have never used a panoramic picture.


Now we will describe several objects:

  • Lens
  • Scenario
  • Content

After the conversion, this figure should look like this.

The so-called lens is the size of our mobile phone screen, whether it is 3.7, 4.3, and so on.
The so-called scenario is the orderly arrangement of all our content, whether it is horizontal (ViewPage), vertical (ListView) and so on.
The so-called content is what is displayed in the camera.
According to the theory of relativity, although we are actually capturing content from a mobile lens to achieve the implementation of the scenario. On the other hand, the camera is still. We use mobile scenes to show the content.

In android, a Scroll class is provided for slide.
If you use Scroller, the process is as follows:

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

2. Override the onInterceptTouchEvent (MotionEvent ev) method to see if you want to intercept the related Click Time.

3. Override the onTouchEvent (MotionEvent event) method and use computeScroll () and scrollTo and scrollBy methods on the touch screen to slide the Layout Based on the fingers.

4. after the touch operation ends (MotionEvent. when ACTION_UP), call the startScroll (int startX, int startY, int dx, int dy, int duration) method to perform automatic animation operations to complete the entire rolling process.

The use of Scroll is as follows:

The difference between ScrollTo and ScrollBy lies in your understanding of To and By. ScrollTo is at that position, while ScrollBy is at this position.

In Android, gestures pass through a VelocityTracker class. Android. View. VelocityTracker is mainly used to track the speed of touch-screen events (flinging and other gestures events.
The general usage is as follows:
When you need to track the speed of touch screen events, use the obtain () method to obtain an Instance Object of the VelocityTracker class.
In the onTouchEvent callback function, use the addMovement (MotionEvent) function to pass the current mobile event to the VelocityTracker object.
Use the computeCurrentVelocity (int units) function to calculate the current speed. Use the getXVelocity () and getYVelocity () functions to obtain the current speed.

Private VelocityTracker mVelocityTracker; // In onTouchEvent (MotionEvent event) if (mVelocityTracker = null) {mVelocityTracker = new VelocityTracker. obtain (); // get the VelocityTracker class instance} mVelocityTracker. addMotionEvent (event); // Add the event to the VelocityTracker class instance. // judge when the ev event is MotionEvent. when ACTION_UP: calculation speed final VelocityTracker velocityTracker = mVelocityTracker; velocityTracker. computerCurrentVelocity (1, (float) 0.01); velocityTracker. computeCurrentVelocity (1000); // set the value of units to 1000, which is the number of pixels that are motion in a second.

Through the past few days of study, there are currently only so many understandings of slide. If this article is helpful to you, it means that my learning is still somewhat fruitful.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.