chunqiuwei / blog_20141113_1_6663175

来自CSDN博客:android事件拦截处理机制---详解 onInterceptTouchEven onTouchEvent http://blog.csdn.net/zhangtian6691844/article/details/51720987#

  最后更新时间 2016-06-20 15:22:56
blog_20141113_1_6663175 21行 Java
Raw
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
<com.example.demo.AView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<com.example.demo.BView
android:layout_width="match_parent"
android:layout_height="match_parent" >

<com.example.demo.CView
android:layout_width="match_parent"
android:layout_height="match_parent" >

<com.example.demo.DView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="测试demo" />
</com.example.demo.CView>
</com.example.demo.BView>

</com.example.demo.AView>
blog_20141113_2_2075922 20行 Java
Raw
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
public class DView extends TextView{
private static String tag = "D";
public DView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}

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

public DView(Context context) {
super(context);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
Log.e(tag, "--onTouchEvent--D");
return false;
}
}
blog_20141113_3_2307060 26行 Java
Raw
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
public class AView extends RelativeLayout{
private static String tag = "A";
public AView(Context context) {
super(context);
}

public AView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}

public AView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
Log.e(tag,"--onInterceptTouchEvent--A");
return false;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
Log.e(tag,"--onTouchEvent---A" );
return false;
}
}
blog_20141113_4_7521688 3行 Java
Raw
 1
 2
 3
if(event.getAction()==MotionEvent.ACTION_MOVE){
Log.e(tag, "--onTouchEvent--*****");
}