• 滑动手势监听类 GestureDetector.OnGestureListener


        /**
         * The listener that is used to notify when gestures occur.
         * If you want to listen for all the different gestures then implement
         * this interface. If you only want to listen for a subset it might
         * be easier to extend {@link SimpleOnGestureListener}.
         */
        public interface OnGestureListener {
    
            /**
             * Notified when a tap occurs with the down {@link MotionEvent}
             * that triggered it. This will be triggered immediately for
             * every down event. All other events should be preceded by this.
             *
             * @param e The down motion event.
             */
            boolean onDown(MotionEvent e);
    
            /**
             * The user has performed a down {@link MotionEvent} and not performed
             * a move or up yet. This event is commonly used to provide visual
             * feedback to the user to let them know that their action has been
             * recognized i.e. highlight an element.
             *
             * @param e The down motion event
             */
            void onShowPress(MotionEvent e);
    
            /**
             * Notified when a tap occurs with the up {@link MotionEvent}
             * that triggered it.
             *
             * @param e The up motion event that completed the first tap
             * @return true if the event is consumed, else false
             */
            boolean onSingleTapUp(MotionEvent e);
    
            /**
             * Notified when a scroll occurs with the initial on down {@link MotionEvent} and the
             * current move {@link MotionEvent}. The distance in x and y is also supplied for
             * convenience.
             *
             * @param e1 The first down motion event that started the scrolling.
             * @param e2 The move motion event that triggered the current onScroll.
             * @param distanceX The distance along the X axis that has been scrolled since the last
             *              call to onScroll. This is NOT the distance between {@code e1}
             *              and {@code e2}.
             * @param distanceY The distance along the Y axis that has been scrolled since the last
             *              call to onScroll. This is NOT the distance between {@code e1}
             *              and {@code e2}.
             * @return true if the event is consumed, else false
             */
            boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY);
    
            /**
             * Notified when a long press occurs with the initial on down {@link MotionEvent}
             * that trigged it.
             *
             * @param e The initial on down motion event that started the longpress.
             */
            void onLongPress(MotionEvent e);
    
            /**
             * Notified of a fling event when it occurs with the initial on down {@link MotionEvent}
             * and the matching up {@link MotionEvent}. The calculated velocity is supplied along
             * the x and y axis in pixels per second.
             *
             * @param e1 The first down motion event that started the fling.
             * @param e2 The move motion event that triggered the current onFling.
             * @param velocityX The velocity of this fling measured in pixels per second
             *              along the x axis.
             * @param velocityY The velocity of this fling measured in pixels per second
             *              along the y axis.
             * @return true if the event is consumed, else false
             */
            boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY);
        }

    Android 屏幕手势滑动中onFling()函数的技巧分析

     android手势处理揭秘

    常用的手势操作有:  拖拽,捏合,旋转,点按,长按, 轻扫
     
     
     
     
     

    缩放手势监听类 ScaleGestureDetector.OnScaleGestureListener

    public float getCurrentSpan ()

    返回手势过程中,组成该手势的两个触点的当前距离。
    返回值
    以像素为单位的触点距离。

    public long getEventTime ()

    返回事件被捕捉时的时间。
    返回值
    以毫秒为单位的事件时间。

    public float getFocusX ()

    返回当前手势焦点的 X 坐标。 如果手势正在进行中,焦点位于组成手势的两个触点之间。 如果手势正在结束,焦点为仍留在屏幕上的触点的位置。若 isInProgress()返回 false,该方法的返回值未定义。
    返回值
    返回焦点的 X 坐标值,以像素为单位。

    public float getFocusY ()

    返回当前手势焦点的 Y 坐标。 如果手势正在进行中,焦点位于组成手势的两个触点之间。 如果手势正在结束,焦点为仍留在屏幕上的触点的位置。若 isInProgress()返回 false,该方法的返回值未定义。
    返回值
    返回焦点的 Y 坐标值,以像素为单位。

    public float getPreviousSpan ()

    返回手势过程中,组成该手势的两个触点的前一次距离。
    返回值
    两点的前一次距离,以像素为单位。

    public float getScaleFactor ()

    返回从前一个伸缩事件至当前伸缩事件的伸缩比率。该值定义为 (getCurrentSpan() / getPreviousSpan())。
    返回值
    当前伸缩比率.

    public long getTimeDelta ()

    返回前一次接收到的伸缩事件距当前伸缩事件的时间差,以毫秒为单位。
    返回值
    从前一次伸缩事件起始的时间差,以毫秒为单位。

    public boolean isInProgress ()

    如果手势处于进行过程中,返回 true.
    返回值
    如果手势处于进行过程中,返回 true。否则返回 false。

  • 相关阅读:
    NGUI Sprite 和 Label 改变Layer 或父物体后 未更新深度问题
    unity销毁层级物体及 NGUI 深度理解总结
    unity 2d 和 NGUI layer
    关于NGUI与原生2D混用相互遮盖的问题心得
    CentOS7为firewalld添加开放端口及相关操作
    Python 操作redis有序集合(sorted set)
    win10下安装redis 服务
    python2/3中 将base64数据写成图片,并将图片数据转为16进制数据的方法、bytes/string的区别
    解决最小化安装Centos7后无法上网的问题,以及安装成功后的基本配置
    在mysql中使用group by和order by取每个分组中日期最大一行数据,亲测有效
  • 原文地址:https://www.cnblogs.com/huyang011/p/7527607.html
Copyright © 2020-2023  润新知