OnClickListener on scrollView

后端 未结 5 1960
眼角桃花
眼角桃花 2020-12-10 11:21

I have a scrollView with lot of elements

ScrollView scroller = (ScrollView)findViewById(R.id.scrollView);

I need to attach an onClickListe

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-10 11:53

    It is because the child of the ScrollView is getting the touch event of the user and not the ScrollView. You must set the clickable=false attribute to each and every child of the ScrollView for the onClickListener to work on ScrollView.

    Or else the alternate could be to set the onClickListener on each of the ScrollView's children and handle it.

提交回复
热议问题