2

我创建了一个包含 ImageView 和 SlidingDrawer 的 RelativeLayout。我在 ImageView 上设置了一个 onClickListener,在 SlidingDrawer 的内容部分设置了另一个。当 SlidingDrawer 打开并单击其内容部分时,会触发 ImageView 的 onClick 事件。

为什么?不是ImageView上面的SlidingDrawer吗?

谢谢

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:background="@drawable/background"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ImageView
        android:id="@+id/whip"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" />  

    <SlidingDrawer
         android:id="@+id/drawer"
         android:layout_width="wrap_content"
         android:layout_height="53dp"
         android:layout_alignParentBottom="true"
         android:orientation="horizontal"

         android:handle="@+id/facebook_icon"
         android:content="@+id/facebook_contacts">

         <ImageView
             android:id="@+id/facebook_icon"
             android:layout_width="55dp"
             android:layout_height="53dp"         
             android:src="@drawable/facebook_handler_off" />

         <ImageView android:id="@+id/facebook_contacts"
                android:layout_width="265dp"
                android:layout_height="53dp"                
                android:src="@drawable/facebook_content" /> 

    </SlidingDrawer>

</RelativeLayout>
4

1 回答 1

1

尝试通过 boolean onInterceptTouchEvent(MotionEvent event) 的实现来拦截鼠标事件

给文档,这个方法“拦截所有触摸屏运动事件”。

如果要使用 SlidingDrawer 处理特定的 MotionEvent(提供参数),则返回 true。

也看看onTouchEvent(MotionEvent event):)

http://developer.android.com/reference/android/widget/SlidingDrawer.html#onInterceptTouchEvent(android.view.MotionEvent )

于 2011-02-28T15:21:05.187 回答