onClick not triggered on LinearLayout with child

后端 未结 15 1102
生来不讨喜
生来不讨喜 2020-11-29 03:33

I\'ve got a custom LinearLayout with a smaller TextView child. I\'d like to be able to click the area not covered by the TextView, so I set clickable=true and an onclicklist

15条回答
  •  广开言路
    2020-11-29 03:46

    The android:duplicateParentState="true" made my TextView looks like it's disabled, and cannot receive click event.

    All you need is set the TextView clickable="false". So the click event will dispatch to parent layout, and the TextView still can react to touch event (with ripple effect).

提交回复
热议问题