Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android TimePicker (Wheel Style) not responding correctly to flick gestures inside ScrollView

I have a dialog box that contains a Scrollview, which contains a layout with two TimePickers.

The timepickers are the newer style ones, what's in ICS.

The problem is that they seem to fight for focus when you change the time by dragging the wheel, or flicking it. It will change the time just a little, and then the layout will scroll instead.

Any ideas? Thanks in advance.

like image 932
int21h Avatar asked Jan 13 '12 07:01

int21h


1 Answers

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:

@Override
public boolean onInterceptTouchEvent(MotionEvent ev)
{
    if (ev.getActionMasked() == MotionEvent.ACTION_DOWN)
    {
        ViewParent p = getParent();
        if (p != null)
            p.requestDisallowInterceptTouchEvent(true);
    }

    return false;
}
like image 57
Klemens Zleptnig Avatar answered Oct 19 '22 11:10

Klemens Zleptnig