package com.cky.learnandroiddetails;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.LinearLayout;

/**
 * Created by cuikangyuan on 16/7/19.
 */
public class MyLayout extends LinearLayout {

    public MyLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        //return super.onInterceptTouchEvent(ev);
        return false;
    }
}

@@ -130,16 +130,53 @@
 nEvent;%0A
+import android.view.VelocityTracker;%0A
 import a
@@ -203,16 +203,16 @@
 Layout;%0A
-
 %0A/**%0A * 
@@ -296,16 +296,55 @@
 yout %7B%0A%0A
+    /*%0A    *Scroller %E5%BC%B9%E6%80%A7%E6%BB%91%E5%8A%A8%E5%AF%B9%E8%B1%A1%0A    * */%0A%0A%0A
     publ
@@ -555,16 +555,16 @@
 nt(ev);%0A
-
         
@@ -582,11 +582,614 @@
 e;%0A    %7D
+%0A%0A    /*%0A    *VelocityTracker %E9%80%9F%E5%BA%A6%E8%BF%BD%E8%B8%AA%0A    * */%0A    @Override%0A    public boolean onTouchEvent(MotionEvent event) %7B%0A%0A        VelocityTracker velocityTracker = VelocityTracker.obtain();%0A        velocityTracker.addMovement(event);%0A%0A        velocityTracker.computeCurrentVelocity(1000);// %E8%AE%A1%E7%AE%97%E9%80%9F%E5%BA%A6 %E4%B8%80%E6%AE%B5%E6%97%B6%E9%97%B4%E5%86%85%E6%89%8B%E6%8C%87%E6%89%80%E5%88%92%E8%BF%87%E7%9A%84%E5%83%8F%E7%B4%A0%E6%95%B0 1000ms%0A        //%E9%80%9F%E5%BA%A6 = (%E7%BB%88%E7%82%B9%E4%BD%8D%E7%BD%AE - %E8%B5%B7%E7%82%B9%E4%BD%8D%E7%BD%AE) / %E6%97%B6%E9%97%B4%0A        int xVelocity = (int) velocityTracker.getXVelocity();%0A        int yVelocity = (int) velocityTracker.getYVelocity();%0A%0A        //%E9%87%8D%E7%BD%AE%E5%9B%9E%E6%94%B6 %E5%86%85%E5%AD%98%0A        velocityTracker.clear();%0A        velocityTracker.recycle();%0A%0A%0A%0A        return super.onTouchEvent(event);%0A    %7D
 %0A%7D%0A

更新 View 相关