Android 2.3 r1 Chinese API (57) -- ScaleGestureDetector

Source: Internet
Author: User
Tags time in milliseconds

 

Preface

This chapter is about android. view. scaleGestureDetector, which allows Views to detect and process gesture changes including multi-touch through the provided MotionEvents. The version is Android 2.3 r1 and translated from "Yixin". Thanks again "Yixin "! I look forward to your participation in Android Chinese API translation, contact me over140@gmail.com.

 

Statement

You are welcome to repost, but please keep the original source of the article :)

Blog Garden: http://www.cnblogs.com/

Android Chinese translation group: http://code.taobao.org/project/view/404/

 

Body

I. Structure

Public class ScaleGestureDetector extends Object

Java. lang. Object

Android. view. ScaleGestureDetector

 

Ii. Overview

Detects deformation gestures caused by multiple contacts (multi-touch) based on the received MotionEvent. The callback method ScaleGestureDetector. OnScaleGestureListener notifies users when a specific gesture event occurs. This class can only be used with MotionEvent triggered by Touch events. To use this class, you must

Create a ScaleGestureDetector instance for your View

Make sure that onTouchEvent (MotionEvent) is called in the onTouchEvent (MotionEvent) method. [Note: the former is the onTouchEvent method of the class, and the latter is the onTouchEvent method of the View.] When an event occurs, the method defined in callback is called.

(Note: ScaleGestureDetector is a new class added to Android2.2, allowing Views to detect and process gesture changes including multi-touch by providing MotionEvents .)

 

Iii. Internal class

Interface ScaleGestureDetector. OnScaleGestureListener

Listener for receiving notifications when a gesture occurs

 

Class ScaleGestureDetector. SimpleOnScaleGestureListener

A convenient class. This class can be inherited if you only want to listen for some scaling events.

 

Iv. Constructor

PublicScaleGestureDetector(Context context, ScaleGestureDetector. OnScaleGestureListener listener)

Constructor

 

V. Public Methods

Public floatGetCurrentSpan()

Returns the current distance between the two contacts that constitute the gesture.

Return Value

The contact distance in pixels.

 

Public longGetEventTime()

Returns the time when an event is captured.

Return Value

Event Time in milliseconds.

 

Public floatGetFocusX()

Returns the X coordinate of the current gesture focus. If the gesture is in progress, the focus is between the two contacts that constitute the gesture. If the gesture is over, the focus is the position of the contact that remains on the screen. If isInProgress () returns false, the return value of this method is undefined.

Return Value

Returns the X coordinate value of the focus, in pixels.

 

Public floatGetFocusY()

Returns the Y coordinate of the current gesture focus. If the gesture is in progress, the focus is between the two contacts that constitute the gesture. If the gesture is over, the focus is the position of the contact that remains on the screen. If isInProgress () returns false, the return value of this method is undefined.

Return Value

Returns the Y coordinate value of the focus, in pixels.

 

Public floatGetpreviusspan()

Returns the first distance between the two contacts that constitute the gesture.

Return Value

The previous distance between two points, in pixels.

 

Public floatGetScaleFactor()

Returns the scaling ratio from the previous scaling event to the current scaling event. This value is defined as (getCurrentSpan ()/getpreviusspan ()).

Return Value

Current scaling ratio.

 

Public longGetTimeDelta()

Returns the time difference between the last received scaling event and the current scaling event, in milliseconds.

Return Value

The time difference from the start of the previous scaling event, in milliseconds.

 

Public booleanIsInProgress()

Returns true if the gesture is in progress.

Return Value

Returns true if the gesture is in progress. Otherwise, false is returned.

 

Vi. Supplement

Article Selection

Android touchexample (Chinese)

Making Sense of Multitouch (android-developers.blogspot.com)

 

End

Yesterday () Android 2.3 r1 has been released, and the translation team quickly switched to the new version of the translation. All newly translated chapters are the latest version. This article is the translation of the trial reviewer "Yixin". Next, he will start the trial review. Thank you for your efforts and contributions.

 

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.