触摸事件的传播

时间:2011-05-16 11:15:37

标签: android touch event-propagation


我有一些ListView。每个列表元素都使用如下布局构建:

<SomeRootLayout android:background="@layout/some_other_selector">
    <TextView android:background="@layout/some_selector"/>
    <TextView android:background="@layout/some_selector"/>
    <ImageView/>
</SomeRootLayout>

some_selector.xml看起来像这样:

<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:state_pressed="true" android:drawable="@drawable/ic_btn_stop_pressed" />

    <item android:drawable="@drawable/ic_btn_stop_default" />
</selector>

现在,当用户按下整行时,每个TextView也被按下(没有真正按下 - 没有生成onClick事件,但TextViews根据其选择器更改其背景)。是否有任何想法告诉系统不要将触摸事件从父视图传播到子视图?

1 个答案:

答案 0 :(得分:2)