I have nested calendarview in ScrollView
. My problem begins when height of view increases.
I can scroll calendar months vertically but when scrollview
scrollbar comes it does not let scroll calendar. Instead of scrolling calendar the whole view scroll up or down.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<LinearLayout android:orientation="vertical" android:id="@+id/ReminderLayout"
android:layout_width="fill_parent" android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="@+id/TaskName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textCapWords"
android:singleLine="true"
android:textSize="26.0sp" />
<View
android:id="@+id/seperator"
android:layout_width="fill_parent"
android:layout_height="1dip" />
<TextView
android:id="@+id/lblNotes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Notes" />
<EditText
android:id="@+id/TaskNotes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:textSize="26.0sp" />
<View
android:id="@+id/seperator"
android:layout_width="fill_parent"
android:layout_height="1dip" />
<TextView
android:id="@+id/lblReminder"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Reminder" />
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="wrap_content">"
<CalendarView
android:id="@+id/calendarReminder"
android:layout_width="fill_parent"
android:layout_height="250dp"
android:scrollbars="vertical"
android:isScrollContainer="true" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TimePicker
android:id="@+id/timePickerReminder"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:gravity="center" />
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content" >
<View android:id="@+id/seperator" android:layout_width="fill_parent" android:layout_height="1dip"/>
<TextView android:id="@+id/ReminderTime" android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="On Time" android:paddingLeft="20dip"/>
<View android:id="@+id/seperator" android:layout_width="fill_parent" android:layout_height="1dip"/>
<TextView android:id="@+id/Recurring" android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="Only Once" android:paddingLeft="20dip"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
Here's one solution, you can implement a custom ScrollView which will only intercept verticale swipe.
"onInterceptTouchEvent" will return false for horizontal swipe, so horizontal swipe will be enable for the CalendarView.
You can read more about this heree : https://stackoverflow.com/a/2655740/5158173
I've found answer to this problem here: https://stackoverflow.com/a/9687545
Basically you need to implement custom CalendarView and override onInterceptTouchEvent method. I did it as following:
Then just use this view in XML layout file: