Android 5.0 Datepicker in scrollview not working (not scrolling months)

I have the new datepicker implemented in an fragment. This is wrapped in a scrollview. When trying to use the datepicker i have to click and hold somewhere on the screen before i can scroll through the datepickers calader to let's say may.

is there a way to fix this?

im using this timepicker:

And im loading it like this:

 <ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/scrollView2"
    android:layout_row="11"
    android:fillViewport="true"
    android:background="#162229"
    android:layout_column="2"
    android:paddingBottom="20dp">
<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:background="#162229"

    android:orientation="vertical" >

    <DatePicker
        android:id="@+id/datePicker1"
        android:layout_width="wrap_content"
        android:background="#162229"
        android:calendarTextColor="#fff"
        android:layout_height="wrap_content"

        android:calendarViewShown="false" > <!-- style="@style/date_picker_style" -->
    </DatePicker>
</LinearLayout>
</ScrollView>

Answers


Create a class that extends DatePicker 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;
}

It'll work fine. source : here


This is because of the parent ScrollView component. Either remove the scroll view or use date picker dialog.


For me, this was useful: How to disable and enable the scrolling on android ScrollView?

Custom scroll view that you lock when appropriate


Need Your Help

FInd if an option has been 'selected' OR 'de-selected' via change event of Select box

javascript jquery html html5 dom

I have a html multi-select select box. When i select/de-select values in a change event is fired on it.