Android-Week-View
Android-Week-View copied to clipboard
A method to disable horizontal scrolling?
Hi! Thanks a lot for the great work on weekview project!
I'm just wondering if a new method can be added to disable horizontal scrolling.
I'm making an app that shows weekly schedules, and previous or next week is unnecessary (as it's obviously same as current week)
It's okay as of now, but it will be a lot better if I can disable horizontal scrolling completely.
Thank you
This would be very helpful!
@wysohn
I fixed this issue by adding new parameter:
private boolean mHorizontalScrollEnabled = true;
Add setter for this parameter
And then add one if into GestureDetector.SimpleOnGestureListener mGestureListener = new GestureDetector.SimpleOnGestureListener() in method onScroll
// Calculate the new origin after scroll. switch (mCurrentScrollDirection) { case LEFT: case RIGHT: if (mHorizontalScrollEnabled) { mCurrentOrigin.x -= distanceX * mXScrollingSpeed; ViewCompat.postInvalidateOnAnimation(WeekView.this); } break;
And also You need to add one more if into onFling method
switch (mCurrentFlingDirection) { case LEFT: case RIGHT: if (mHorizontalFlingEnabled) { mScroller.fling((int) mCurrentOrigin.x, (int) mCurrentOrigin.y, (int) (velocityX * mXScrollingSpeed), 0, Integer.MIN_VALUE, Integer.MAX_VALUE, (int) -(mHourHeight * 24 + mHeaderTextHeight + mHeaderRowPadding * 2 + mHeaderMarginBottom + mTimeTextHeight / 2 - getHeight()), 0); } `break;
add this to your weekview app:xScrollingSpeed="0.0"
@FnR2 this is work for me