Android: How to propagate click event to LinearLayout childs and change their drawable

后端 未结 5 1727
灰色年华
灰色年华 2021-01-31 10:05

I would like to create a linear layout which would behave similarly to ImageButton.



        
5条回答
  •  有刺的猬
    2021-01-31 10:39

    At first, my child view failed to get click from parent. After investigating, what I need to do to make it work are:

    1. remove click listener on child view
    2. adding click listener on parent view

    So, I don't need to add these on every children.

    android:duplicateParentState="true"
    android:clickable="false"
    

    I only add duplicateParentState to one of my child view.

    My child view is now listening to parent click event.

提交回复
热议问题