Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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: enter image description here

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>
like image 679
Twizzler Avatar asked Apr 01 '15 08:04

Twizzler


1 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

like image 53
S.Thiongane Avatar answered Oct 07 '22 00:10

S.Thiongane