Android-Week-View icon indicating copy to clipboard operation
Android-Week-View copied to clipboard

A method to disable horizontal scrolling?

Open wysohn opened this issue 7 years ago • 4 comments

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

wysohn avatar May 02 '17 19:05 wysohn

This would be very helpful!

kamiljeglikowski avatar Aug 02 '17 13:08 kamiljeglikowski

@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;

kamiljeglikowski avatar Aug 02 '17 13:08 kamiljeglikowski

add this to your weekview app:xScrollingSpeed="0.0"

FnR2 avatar Sep 03 '17 22:09 FnR2

@FnR2 this is work for me

jokopriyono avatar Apr 10 '18 06:04 jokopriyono