Android and buttons inside scroll views
I have a scrollview whose child con开发者_运维问答tains a button. If the user tries to scroll with their finger over the button, I want the view to scroll without the button being clicked. In other words, I want the scroll view to consume the event.
How can I achieve this?
you will have to create a custom button for your purpose , which will overwrite the on touch listeners of the button. you will have to disable the on touch listeners in your custom button. Then only scroll view will be effected.
You can implement onTouch of your button with nothing than
return true;
this will make the button not consume the Event.
That's already handled. I've just implemented the same myself, a list of buttons in a scrollview, and a click+drag doesn't activate the button.
All you have to do is set "setClickable(false)" for your button
精彩评论