Android-PickerView 滑动到底部或者顶部的时候,还未完全滑到头就滑不动了,在选择项少的情况下体验不好,

shyt4zoc  于 2022-10-22  发布在  Android
关注(0)|答案(3)|浏览(174)

滑动到底部或者顶部的时候,还未完全滑到头就滑不动了,在选择项少的情况下体验不好。

svmlkihl

svmlkihl1#

+1

楼主有解决办法吗

y1aodyip

y1aodyip2#

看源码onTouchEvent的边界条件好像不太对:

case MotionEvent.ACTION_MOVE:
                float dy = previousY - event.getRawY();
                previousY = event.getRawY();
                totalScrollY = totalScrollY + dy;

                // normal mode。
                if (!isLoop) {
                    if ((totalScrollY - itemHeight * ratio < top && dy < 0)
                            || (totalScrollY + itemHeight * ratio > bottom && dy > 0)) {
                        //快滑动到边界了,设置已滑动到边界的标志
                        totalScrollY -= dy;
                        isIgnore = true;
                    } else {
                        isIgnore = false;
                    }
                }
                break;

我现在改成这样了貌似暂时解决了

case MotionEvent.ACTION_MOVE:
                float dy = previousY - event.getRawY();
                previousY = event.getRawY();
                totalScrollY = totalScrollY + dy;

                // normal mode。
                if (!isLoop) {
                    if (dy > 0 && totalScrollY >= bottom) {
                        totalScrollY = bottom;
//                        isIgnore = true;
                    } else if (dy < 0 && totalScrollY <= top) {
                        totalScrollY = top;
//                        isIgnore = true;
                    } else {
                        isIgnore = false;
                    }
moiiocjp

moiiocjp3#

我是把ratio原来0.25改成0.05------------------ 原始邮件 ------------------ 发件人: "Mahao"notifications@github.com 发送时间: 2019年5月7日(星期二) 下午4:37 收件人: "Bigkoo/Android-PickerView"Android-PickerView@noreply.github.com; 抄送: "mingzaizai"384627918@qq.com;"Author"author@noreply.github.com; 主题: Re: [Bigkoo/Android-PickerView] 滑动到底部或者顶部的时候,还未完全滑到头就滑不动了,在选择项少的情况下体验不好。 (#548) 看源码onTouchEvent的边界条件好像不太对: case MotionEvent.ACTION_MOVE: float dy = previousY - event.getRawY(); previousY = event.getRawY(); totalScrollY = totalScrollY + dy; // normal mode。 if (!isLoop) { if ((totalScrollY - itemHeight * ratio < top && dy < 0) || (totalScrollY + itemHeight * ratio > bottom && dy > 0)) { //快滑动到边界了,设置已滑动到边界的标志 totalScrollY -= dy; isIgnore = true; } else { isIgnore = false; } } break; 我现在改成这样了貌似暂时解决了 case MotionEvent.ACTION_MOVE: float dy = previousY - event.getRawY(); previousY = event.getRawY(); totalScrollY = totalScrollY + dy; // normal mode。 if (!isLoop) { if (dy > 0 && totalScrollY >= bottom) { totalScrollY = bottom; // isIgnore = true; } else if (dy < 0 && totalScrollY <= top) { totalScrollY = top; // isIgnore = true; } else { isIgnore = false; } — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

相关问题