1.触摸事件的类型
触摸事件对应MotionEvent类,事件的类型主要有如下三种:
1.1 ACTION_DOWN:
用户手指按下操作,标志着一次触摸事件的开始。
1.2 ACTION_MOVE:
用户手指按压屏幕后,在松开之前,如果移动的距离超过一定的阈值,那么就会判定为移动事件。我们手指的轻微移动,就会触发一系列的移动事件。
1.3 ACTION_UP:
用户手指离开屏幕,一次抬起操作标志着一次触摸事件的结束。
2.事件传递的三个阶段
2.1 分发(Dispatch)
事件的分发对应着dispatchTouchEvent方法,再Android系统中,所有的触摸事件都是通过这个方法来分发的。在这个方法中,根据返回值true或者false来决定是直接消费这个事件还是继续分发给子视图处理,如果当前视图是ViewGroup及其子类,则会调onInterceptTouchEvent方法来决定是否拦截该事件。
2.2 拦截(Intercept)
事件的拦截对应着onInterceptTouchEvent方法。这个方法只在ViewGroup及其子类中存在,在View和Activity中是不存在的。
2.3 消费 (Consume)
事件的消费对应onTouchEvent方法。
3.实例讲解(通过下面的日志可以看出事件的传递流程):
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<com.example.androidreview.view.MyTextView
android:id="@+id/mytext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="View的事件传递机制" />
<com.example.androidreview.view.MyRelativelayout
android:id="@+id/myRela"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.example.androidreview.view.MyTextView
android:id="@+id/mytextInMyRela"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="ViewGroup的事件传递机制" />
</com.example.androidreview.view.MyRelativelayout>
</LinearLayout>
MainActivity
public class MainActivity extends Activity {
private static final String TAG = "MainActivity_JXD";
private MyTextView myTextView = null;
private MyRelativelayout myRelativelayout = null;
private MyTextView myTextViewInRela = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myTextView = findViewById(R.id.mytext);
myRelativelayout = findViewById(R.id.myRela);
myTextViewInRela = findViewById(R.id.mytextInMyRela);
myTextView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
Log.d(TAG,"onTouch ACTION_DOWN");
break;
case MotionEvent.ACTION_MOVE:
Log.d(TAG,"onTouch ACTION_MOVE");
break;
case MotionEvent.ACTION_UP:
Log.d(TAG,"onTouch ACTION_UP");
break;
case MotionEvent.ACTION_CANCEL:
Log.d(TAG,"onTouch ACTION_CANCEL");
break;
default:
break;
}
return false;
}
});
myRelativelayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d(TAG,"myRelativelayout onClick...");
}
});
myRelativelayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
Log.d(TAG,"myRelativelayout onTouch ACTION_DOWN");
break;
case MotionEvent.ACTION_MOVE:
Log.d(TAG,"myRelativelayout onTouch ACTION_MOVE");
break;
case MotionEvent.ACTION_UP:
Log.d(TAG,"myRelativelayout onTouch ACTION_UP");
break;
case MotionEvent.ACTION_CANCEL:
Log.d(TAG,"myRelativelayout onTouch ACTION_CANCEL");
break;
default:
break;
}
return false;
}
});
myTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d(TAG,"myTextView onClick...");
}
});
myTextViewInRela.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d(TAG,"myTextViewInRela onClick...");
}
});
myTextViewInRela.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
Log.d(TAG,"myTextViewInRela onTouch ACTION_DOWN");
break;
case MotionEvent.ACTION_MOVE:
Log.d(TAG,"myTextViewInRela onTouch ACTION_MOVE");
break;
case MotionEvent.ACTION_UP:
Log.d(TAG,"myTextViewInRela onTouch ACTION_UP");
break;
case MotionEvent.ACTION_CANCEL:
Log.d(TAG,"myTextViewInRela onTouch ACTION_CANCEL");
break;
default:
break;
}
return false;
}
});
}
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
Log.d(TAG,"dispatchTouchEvent ACTION_DOWN");
break;
case MotionEvent.ACTION_MOVE:
Log.d(TAG,"dispatchTouchEvent ACTION_MOVE");
break;
case MotionEvent.ACTION_UP:
Log.d(TAG,"dispatchTouchEvent ACTION_UP");
break;
case MotionEvent.ACTION_CANCEL:
Log.d(TAG,"dispatchTouchEvent ACTION_CANCEL");
break;
default:
break;
}
return super.dispatchTouchEvent(event);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
Log.d(TAG,"onTouchEvent ACTION_DOWN");
break;
case MotionEvent.ACTION_MOVE:
Log.d(TAG,"onTouchEvent ACTION_MOVE");
break;
case MotionEvent.ACTION_UP:
Log.d(TAG,"onTouchEvent ACTION_UP");
break;
case MotionEvent.ACTION_CANCEL:
Log.d(TAG,"onTouchEvent ACTION_CANCEL");
break;
default:
break;
}
return super.onTouchEvent(event);
}
}
MyTextView
public class MyTextView extends TextView {
private static final String TAG = "MyTextView_JXD";
public MyTextView(Context context) {
super(context);
}
public MyTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
Log.d(TAG,"dispatchTouchEvent ACTION_DOWN");
break;
case MotionEvent.ACTION_MOVE:
Log.d(TAG,"dispatchTouchEvent ACTION_MOVE");
break;
case MotionEvent.ACTION_UP:
Log.d(TAG,"dispatchTouchEvent ACTION_UP");
break;
case MotionEvent.ACTION_CANCEL:
Log.d(TAG,"dispatchTouchEvent ACTION_CANCEL");
break;
default:
break;
}
return super.dispatchTouchEvent(event);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
Log.d(TAG,"onTouchEvent ACTION_DOWN");
break;
case MotionEvent.ACTION_MOVE:
Log.d(TAG,"onTouchEvent ACTION_MOVE");
break;
case MotionEvent.ACTION_UP:
Log.d(TAG,"onTouchEvent ACTION_UP");
break;
case MotionEvent.ACTION_CANCEL:
Log.d(TAG,"onTouchEvent ACTION_CANCEL");
break;
default:
break;
}
return super.onTouchEvent(event);
}
}
MyRelativelayout
public class MyRelativelayout extends RelativeLayout {
private static final String TAG = "MyRelativelayout";
public MyRelativelayout(Context context) {
super(context);
}
public MyRelativelayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
Log.d(TAG,"dispatchTouchEvent ACTION_DOWN");
break;
case MotionEvent.ACTION_MOVE:
Log.d(TAG,"dispatchTouchEvent ACTION_MOVE");
break;
case MotionEvent.ACTION_UP:
Log.d(TAG,"dispatchTouchEvent ACTION_UP");
break;
case MotionEvent.ACTION_CANCEL:
Log.d(TAG,"dispatchTouchEvent ACTION_CANCEL");
break;
default:
break;
}
return super.dispatchTouchEvent(event);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
Log.d(TAG,"onTouchEvent ACTION_DOWN");
break;
case MotionEvent.ACTION_MOVE:
Log.d(TAG,"onTouchEvent ACTION_MOVE");
break;
case MotionEvent.ACTION_UP:
Log.d(TAG,"onTouchEvent ACTION_UP");
break;
case MotionEvent.ACTION_CANCEL:
Log.d(TAG,"onTouchEvent ACTION_CANCEL");
break;
default:
break;
}
return super.onTouchEvent(event);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
Log.d(TAG,"onInterceptTouchEvent ACTION_DOWN");
break;
case MotionEvent.ACTION_MOVE:
Log.d(TAG,"onInterceptTouchEvent ACTION_MOVE");
break;
case MotionEvent.ACTION_UP:
Log.d(TAG,"onInterceptTouchEvent ACTION_UP");
break;
case MotionEvent.ACTION_CANCEL:
Log.d(TAG,"onInterceptTouchEvent ACTION_CANCEL");
break;
default:
break;
}
return super.onInterceptTouchEvent(event);
}
}
当按下立刻松开(View的事件传递机制按钮)时的日志:
* 11-16 10:21:36.032 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_DOWN
* 11-16 10:21:36.032 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_DOWN
* 11-16 10:21:36.032 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_DOWN
* 11-16 10:21:36.032 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_DOWN
* 11-16 10:21:36.085 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_UP
* 11-16 10:21:36.085 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_UP
* 11-16 10:21:36.085 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_UP
* 11-16 10:21:36.085 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_UP
* 11-16 10:21:36.086 6035-6035/com.example.androidreview D/MainActivity_JXD: myTextView onClick...
当按下稍微划动一下,再离开(View的事件传递机制按钮)时的日志:
* 11-16 10:24:00.204 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_DOWN
* 11-16 10:24:00.204 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_DOWN
* 11-16 10:24:00.204 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_DOWN
* 11-16 10:24:00.204 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_DOWN
* 11-16 10:24:00.317 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.318 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.318 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_MOVE
* 11-16 10:24:00.318 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:24:00.535 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.535 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.535 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_MOVE
* 11-16 10:24:00.535 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:24:00.552 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.552 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.552 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_MOVE
* 11-16 10:24:00.552 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:24:00.568 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.568 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.568 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_MOVE
* 11-16 10:24:00.568 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:24:00.585 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.585 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.585 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_MOVE
* 11-16 10:24:00.585 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:24:00.602 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.602 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.602 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_MOVE
* 11-16 10:24:00.602 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:24:00.619 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.619 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.619 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_MOVE
* 11-16 10:24:00.619 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:24:00.635 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.635 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.635 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_MOVE
* 11-16 10:24:00.635 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:24:00.652 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.652 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.652 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_MOVE
* 11-16 10:24:00.652 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:24:00.669 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.669 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.669 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_MOVE
* 11-16 10:24:00.669 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:24:00.685 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.685 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.686 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_MOVE
* 11-16 10:24:00.686 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:24:00.702 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.702 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.702 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_MOVE
* 11-16 10:24:00.702 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:24:00.719 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.719 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.719 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_MOVE
* 11-16 10:24:00.719 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:24:00.736 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.736 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.736 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_MOVE
* 11-16 10:24:00.736 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:24:00.752 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.752 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.753 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_MOVE
* 11-16 10:24:00.753 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:24:00.769 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.769 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.769 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_MOVE
* 11-16 10:24:00.769 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:24:00.801 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.801 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:24:00.801 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_MOVE
* 11-16 10:24:00.801 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:24:00.801 6035-6035/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_UP
* 11-16 10:24:00.801 6035-6035/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_UP
* 11-16 10:24:00.801 6035-6035/com.example.androidreview D/MainActivity_JXD: onTouch ACTION_UP
* 11-16 10:24:00.801 6035-6035/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_UP
* 11-16 10:24:00.801 6035-6035/com.example.androidreview V/SettingsInterface: from settings cache , name = sound_effects_enabled , value = 0
* 11-16 10:24:00.801 6035-6035/com.example.androidreview D/MainActivity_JXD: myTextView onClick...
当按下立刻松开 (ViewGroup的事件传递机制) 按钮时日志为:
* 11-16 10:46:28.038 6838-6838/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_DOWN
* 11-16 10:46:28.038 6838-6838/com.example.androidreview D/MyRelativelayout: dispatchTouchEvent ACTION_DOWN
* 11-16 10:46:28.038 6838-6838/com.example.androidreview D/MyRelativelayout: onInterceptTouchEvent ACTION_DOWN
* 11-16 10:46:28.038 6838-6838/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_DOWN
* 11-16 10:46:28.038 6838-6838/com.example.androidreview D/MainActivity_JXD: myTextViewInRela onTouch ACTION_DOWN
* 11-16 10:46:28.038 6838-6838/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_DOWN
* 11-16 10:46:28.111 6838-6838/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_UP
* 11-16 10:46:28.111 6838-6838/com.example.androidreview D/MyRelativelayout: dispatchTouchEvent ACTION_UP
* 11-16 10:46:28.111 6838-6838/com.example.androidreview D/MyRelativelayout: onInterceptTouchEvent ACTION_UP
* 11-16 10:46:28.111 6838-6838/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_UP
* 11-16 10:46:28.111 6838-6838/com.example.androidreview D/MainActivity_JXD: myTextViewInRela onTouch ACTION_UP
* 11-16 10:46:28.111 6838-6838/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_UP
* 11-16 10:46:28.112 6838-6838/com.example.androidreview V/SettingsInterface: from settings cache , name = sound_effects_enabled , value = 0
* 11-16 10:46:28.112 6838-6838/com.example.androidreview D/MainActivity_JXD: myTextViewInRela onClick...
当按下稍微划动一下,再离开日 (ViewGroup的事件传递机制) 按钮时日志为:
* 11-16 10:48:36.248 6838-6838/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_DOWN
* 11-16 10:48:36.251 6838-6838/com.example.androidreview D/MyRelativelayout: dispatchTouchEvent ACTION_DOWN
* 11-16 10:48:36.251 6838-6838/com.example.androidreview D/MyRelativelayout: onInterceptTouchEvent ACTION_DOWN
* 11-16 10:48:36.251 6838-6838/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_DOWN
* 11-16 10:48:36.251 6838-6838/com.example.androidreview D/MainActivity_JXD: myTextViewInRela onTouch ACTION_DOWN
* 11-16 10:48:36.251 6838-6838/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_DOWN
* 11-16 10:48:36.278 6838-6838/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.278 6838-6838/com.example.androidreview D/MyRelativelayout: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.278 6838-6838/com.example.androidreview D/MyRelativelayout: onInterceptTouchEvent ACTION_MOVE
* 11-16 10:48:36.278 6838-6838/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.278 6838-6838/com.example.androidreview D/MainActivity_JXD: myTextViewInRela onTouch ACTION_MOVE
* 11-16 10:48:36.278 6838-6838/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:48:36.312 6838-6838/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.312 6838-6838/com.example.androidreview D/MyRelativelayout: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.312 6838-6838/com.example.androidreview D/MyRelativelayout: onInterceptTouchEvent ACTION_MOVE
* 11-16 10:48:36.312 6838-6838/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.312 6838-6838/com.example.androidreview D/MainActivity_JXD: myTextViewInRela onTouch ACTION_MOVE
* 11-16 10:48:36.312 6838-6838/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:48:36.345 6838-6838/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.345 6838-6838/com.example.androidreview D/MyRelativelayout: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.345 6838-6838/com.example.androidreview D/MyRelativelayout: onInterceptTouchEvent ACTION_MOVE
* 11-16 10:48:36.345 6838-6838/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.345 6838-6838/com.example.androidreview D/MainActivity_JXD: myTextViewInRela onTouch ACTION_MOVE
* 11-16 10:48:36.345 6838-6838/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:48:36.362 6838-6838/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.362 6838-6838/com.example.androidreview D/MyRelativelayout: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.362 6838-6838/com.example.androidreview D/MyRelativelayout: onInterceptTouchEvent ACTION_MOVE
* 11-16 10:48:36.362 6838-6838/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.362 6838-6838/com.example.androidreview D/MainActivity_JXD: myTextViewInRela onTouch ACTION_MOVE
* 11-16 10:48:36.362 6838-6838/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:48:36.378 6838-6838/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.379 6838-6838/com.example.androidreview D/MyRelativelayout: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.379 6838-6838/com.example.androidreview D/MyRelativelayout: onInterceptTouchEvent ACTION_MOVE
* 11-16 10:48:36.379 6838-6838/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.379 6838-6838/com.example.androidreview D/MainActivity_JXD: myTextViewInRela onTouch ACTION_MOVE
* 11-16 10:48:36.379 6838-6838/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:48:36.395 6838-6838/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.395 6838-6838/com.example.androidreview D/MyRelativelayout: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.395 6838-6838/com.example.androidreview D/MyRelativelayout: onInterceptTouchEvent ACTION_MOVE
* 11-16 10:48:36.395 6838-6838/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.395 6838-6838/com.example.androidreview D/MainActivity_JXD: myTextViewInRela onTouch ACTION_MOVE
* 11-16 10:48:36.395 6838-6838/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:48:36.412 6838-6838/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.412 6838-6838/com.example.androidreview D/MyRelativelayout: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.412 6838-6838/com.example.androidreview D/MyRelativelayout: onInterceptTouchEvent ACTION_MOVE
* 11-16 10:48:36.412 6838-6838/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_MOVE
* 11-16 10:48:36.412 6838-6838/com.example.androidreview D/MainActivity_JXD: myTextViewInRela onTouch ACTION_MOVE
* 11-16 10:48:36.412 6838-6838/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_MOVE
* 11-16 10:48:36.422 6838-6838/com.example.androidreview D/MainActivity_JXD: dispatchTouchEvent ACTION_UP
* 11-16 10:48:36.422 6838-6838/com.example.androidreview D/MyRelativelayout: dispatchTouchEvent ACTION_UP
* 11-16 10:48:36.422 6838-6838/com.example.androidreview D/MyRelativelayout: onInterceptTouchEvent ACTION_UP
* 11-16 10:48:36.422 6838-6838/com.example.androidreview D/MyTextView_JXD: dispatchTouchEvent ACTION_UP
* 11-16 10:48:36.422 6838-6838/com.example.androidreview D/MainActivity_JXD: myTextViewInRela onTouch ACTION_UP
* 11-16 10:48:36.422 6838-6838/com.example.androidreview D/MyTextView_JXD: onTouchEvent ACTION_UP
* 11-16 10:48:36.422 6838-6838/com.example.androidreview V/SettingsInterface: from settings cache , name = sound_effects_enabled , value = 0
* 11-16 10:48:36.422 6838-6838/com.example.androidreview D/MainActivity_JXD: myTextViewInRela onClick...