android TouchEvent 传递过程

<div id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:0c8ad334-6609-4c3f-91dd-00eda8ed4860" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"><pre class="brush: java; gutter: true; first-line: 1; tab-size: 4; toolbar: true; width: 640px; height: 511px;" style=" width: 640px; height: 511px;overflow: auto;">package com.example.toucheventtest;

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

public class TouchView extends LinearLayout{

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

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
	Log.i(&quot;test&quot;,&quot;dispatchKeyEvent&quot;);
	return super.dispatchKeyEvent(event);
}

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
	Log.i(&quot;test&quot;,&quot;dispatchTouchEvent&quot;);
	return super.dispatchTouchEvent(ev);
}

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
	Log.i(&quot;test&quot;,&quot;onInterceptTouchEvent&quot;);
	return super.onInterceptTouchEvent(ev);
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
	Log.i(&quot;test&quot;,&quot;onKeyDown&quot;);
	return super.onKeyDown(keyCode, event);
}

@Override
public boolean onTouchEvent(MotionEvent event) {
	Log.i(&quot;test&quot;,&quot;onTouchEvent&quot;);
	return super.onTouchEvent(event);
}

} </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div>

<p> <div id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:3e11d691-9bba-40e3-88c4-6bc3c90022d5" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"><pre class="brush: java; gutter: true; first-line: 1; tab-size: 4; toolbar: true; width: 638px; height: 529px;" style=" width: 638px; height: 529px;overflow: auto;">package com.example.toucheventtest;

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

public class TouchViewSub extends LinearLayout{

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

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
	Log.i(&quot;test&quot;,&quot;dispatchKeyEvent TouchViewSub&quot;);
	return super.dispatchKeyEvent(event);
}

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
	Log.i(&quot;test&quot;,&quot;dispatchTouchEvent TouchViewSub&quot;);
	return super.dispatchTouchEvent(ev);
}

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
	Log.i(&quot;test&quot;,&quot;onInterceptTouchEvent TouchViewSub&quot;);
	return super.onInterceptTouchEvent(ev);
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
	Log.i(&quot;test&quot;,&quot;onKeyDown TouchViewSub&quot;);
	return super.onKeyDown(keyCode, event);
}

@Override
public boolean onTouchEvent(MotionEvent event) {
	Log.i(&quot;test&quot;,&quot;onTouchEvent TouchViewSub&quot;);
	return super.onTouchEvent(event);
}

} </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div>

</p>

<p>&#160;</p>

<div id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:2bd43dd7-f8f9-42a7-b7cd-a6e7fbad16b9" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"><pre class="brush: xml; gutter: true; first-line: 1; tab-size: 4; toolbar: true; width: 638px; height: 529px;" style=" width: 638px; height: 529px;overflow: auto;">&lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; xmlns:tools=&quot;http://schemas.android.com/tools&quot; android:layout_width=&quot;match_parent&quot; android:layout_height=&quot;match_parent&quot; android:paddingBottom=&quot;@dimen/activity_vertical_margin&quot; android:paddingLeft=&quot;@dimen/activity_horizontal_margin&quot; android:paddingRight=&quot;@dimen/activity_horizontal_margin&quot; android:paddingTop=&quot;@dimen/activity_vertical_margin&quot; tools:context=&quot;.MainActivity&quot; &gt;

&lt;com.example.toucheventtest.TouchView
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;
    android:orientation=&quot;vertical&quot; &gt;

    &lt;com.example.toucheventtest.TouchViewSub
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:orientation=&quot;vertical&quot; &gt;

        &lt;TextView
            android:layout_width=&quot;fill_parent&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;aaaaaaaaaaaaaaaaaaaa&quot; /&gt;

        &lt;TextView
            android:layout_width=&quot;fill_parent&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;aaaadddfdfdfdfdfddf&quot; /&gt;
    &lt;/com.example.toucheventtest.TouchViewSub&gt;
&lt;/com.example.toucheventtest.TouchView&gt;

</RelativeLayout></pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div>

<p><a href="http://static.oschina.net/uploads/img/201305/23103242_axQQ.png"><img title="截图1369276273" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="截图1369276273" src="http://static.oschina.net/uploads/img/201305/23103242_wOoI.png" width="624" height="94" /></a></p>

转载于:https://my.oschina.net/muchenshou/blog/132835

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值