wheelview 网络版很好,根据实际需要修改一下,谢谢写出代码的前辈们
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {int touchY=(int)e.getY();
int center=DEF_VISIBLE_ITEMS/2;
Rect bounds = new Rect();
itemsLayout.getLineBounds(center, bounds);
int line = center;
if (touchY < bounds.top) {
line--;
while (line >= 0) {
itemsLayout.getLineBounds(line, bounds);
if (touchY >= bounds.top && touchY <= bounds.bottom) {
break;
}
line--;
}
} else if (touchY > bounds.bottom) {
line++;
while (line <= DEF_VISIBLE_ITEMS ) {
itemsLayout.getLineBounds(line, bounds);
if (touchY >= bounds.top && touchY <= bounds.bottom) {
break;
}
line++;
}
}
scroller.startScroll(0, lastScrollY, 0, (line - center)*getItemHeight()+scrollingOffset);
setNextMessage(MESSAGE_SCROLL);
return true;
}
本文介绍了一个基于WheelView网络版的实现方案,针对单击确认功能进行了详细解析。通过对触摸位置的判断,实现了当用户点击时,轮播视图能够准确地定位到被点击的选项并进行相应的滚动操作。
622

被折叠的 条评论
为什么被折叠?



