android-touch-event

Can we use scale gesture detector for pinch zoom in Android?

巧了我就是萌 提交于 2019-11-26 09:26:29
问题 Can we use scale gesture detector for pinch zoom in Android? 回答1: You can use this import android.content.Context; import android.graphics.Canvas; import android.graphics.drawable.BitmapDrawable; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.view.ScaleGestureDetector; import android.view.View; public class MyImageView extends View { private static final int INVALID_POINTER_ID = -1; private Drawable mImage; private float mPosX;

Android: Difference between onInterceptTouchEvent and dispatchTouchEvent?

半城伤御伤魂 提交于 2019-11-26 02:59:38
问题 What is the difference between onInterceptTouchEvent and dispatchTouchEvent in Android? According to the android developer guide, both methods can be used to intercept a touch event ( MotionEvent ), but what is the difference? How do onInterceptTouchEvent , dispatchTouchEvent and onTouchEvent interact together within a hierarchy of Views ( ViewGroup )? 回答1: The best place to demystify this is the source code. The docs are woefully inadequate about explaining this. dispatchTouchEvent is