Android TimePicker (Wheel Style) not responding correctly to flick gestures inside ScrollView
I had the same problem when using the Holo theme, and here is where I found the solution: https://groups.google.com/forum/?fromgroups#!topic/android-developers/FkSfJI6dH8w
You must implement your custom DatePicker or TimePicker and override the following method:
@Overridepublic boolean onInterceptTouchEvent(MotionEvent ev){ if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) { ViewParent p = getParent(); if (p != null) p.requestDisallowInterceptTouchEvent(true); } return false;}
Because the link from Klemens Zleptnig is broken, here is a complete example. This fix helps with the scroll of a TabLayout too btw. I excluded the area around the big numbers in the top of the TimePicker because they don't need the scroll event anyway.
xml:
<com.name.app.MyTimePicker android:id="@+id/timePicker" android:layout_width="wrap_content" android:layout_height="wrap_content".../>
java:
public class MyTimePicker extends TimePicker { public MyTimePicker(Context context) { super(context); } //This is the important constructor public MyTimePicker(Context context, AttributeSet attrs) { super(context, attrs); } public MyTimePicker(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public MyTimePicker(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) { //Excluding the top of the view if(ev.getY() < getHeight()/3.3F) return false; ViewParent p = getParent(); if (p != null) p.requestDisallowInterceptTouchEvent(true); } return false; }}