Make linear layout selectable like a list item in a list view (Android)

后端 未结 3 1095
太阳男子
太阳男子 2021-02-02 11:01

I know how to add an onClick listener to a LinearLayout to make the whole layout a click target, but I\'d like to have the LinearLayout get highlighted when tapped just like a l

3条回答
  •  深忆病人
    2021-02-02 11:26

    You can set all the elements inside the layout clickable=false. Then you should mimic selection behavior by setting layout background to some color and set all the other ones with background transparent when a layout is clicked. You can use layout id as index to know which layout is selected.

提交回复
热议问题