I have nested calendarview in ScrollView
. My problem begins when height of view increases.
I can scroll calendar months vertically but when scrollview
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:
package com.example.app.views;
public class CalendarViewScrollable extends CalendarView {
public CalendarViewScrollable(Context context) {
super(context);
}
public CalendarViewScrollable(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CalendarViewScrollable(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev)
{
if (ev.getActionMasked() == MotionEvent.ACTION_DOWN)
{
ViewParent p = getParent();
if (p != null)
p.requestDisallowInterceptTouchEvent(true);
}
return false;
}
}
Then just use this view in XML layout file:
<com.example.app.views.CalendarViewScrollable
android:id="@+id/datePicker1"
android:layout_width="400dp"
android:layout_height="400dp"
/>
Here's one solution, you can implement a custom ScrollView which will only intercept verticale swipe.
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {...}
"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