Disable scroll but allow tap on item
See original GitHub issue@kizitonwose I’m stuck with the following situacion…
On one hand I need to disable the horizontal scrolling on the calendar as shown on here: https://github.com/kizitonwose/CalendarView/issues/13 and do it programatically.
But at the same time I need to be able to tap/click on days of the calendar (by setting a click listener on the DayViewContainer view):
view.setOnClickListener(new View.OnClickListener()...
The problem is that by disabling the scroll I’m intercepting the Action.MOVE used by the taps as well, therefore onInterceptTouchEvent is swallowing the event, hence not allowing it to reach the defined view click listener.
So to sum up I need to disable the swiping of the calendar but allowing taps of each of days of the calendar…
Any suggestion?
Thanks in advance,
Federico
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Closing this issue as there’s now a solution. If you need any further assistance, let me know.
I finally got my hands on a Samsung device and can confirm that the suggested workaround does not work on the device.
However, after further testing, there’s another workaround which works on Samsung devices as well as other devices which I tested on:
For reference purposes, here are other things I tried and how they turned out.
The above workaround allows an initial scroll action on the calendar before taking effect which is rather weird.
Another option is to extend the
CalenderView
class and override thedispatchTouchEvent
method.This gives the desired result. However, while the calendar does not move after a swipe action, a touch event is registered at the start position of the swipe gesture, hence the date cell at that position receives a click event.