Search code examples
androidtouchevent-propagation

Propagation of touch events



I've got some ListView. Each list element is constructed using layout looking like this:

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

The some_selector.xml is looking like this:

<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>

Now, when the user press the entire row, the each TextView is being pressed as well (not really pressed - no onClick events are generated, however TextViews change its background according to their selectors). Any ideas to tell system NOT to propagate touch events from parent to child views?


Solution

  • You can set android:duplicateParentState="false" on your textview