问题描述
例如,当我移动 circleseekbar 滑块时,滚动视图也会起作用,从而将整个布局向上移动,我只需要能够更改滑块的位置。
尝试过 android:scrollbars = "none"
- 一切都失败了。
解决方法
您需要暂时停止 WITH seat_count AS(
SELECT COUNT(*) AS counts
FROM seat)
SELECT
(CASE
WHEN MOD(id,2)!= 0 AND counts != id THEN id+1
WHEN MOD(id,2)!= 0 AND counts = id THEN id
ELSE id-1
END) AS id,student
FROM seat
CROSS JOIN seat_count
ORDER BY id ASC
滚动并在您完成对 ScrollView
的操作后重新启用它。
要实现这一点:不要使用 SeekBar
,而是使用以下自定义的方法,其中 Overriding ScrollView
起到了作用。
onInterceptTouchEvent
您可以通过调用public class LockableScrollView extends ScrollView {
// true if we can scroll (not locked)
// false if we cannot scroll (locked)
private boolean mScrollable = true;
public LockableScrollView(Context context) {
super(context);
}
public LockableScrollView(Context context,AttributeSet attrs) {
super(context,attrs);
}
public LockableScrollView(Context context,AttributeSet attrs,int defStyleAttr) {
super(context,attrs,defStyleAttr);
}
public void setScrollingEnabled(boolean enabled) {
mScrollable = enabled;
}
public boolean isScrollable() {
return mScrollable;
}
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {// if we can scroll pass the event to the superclass
return mScrollable && super.onTouchEvent(ev);
}
return super.onTouchEvent(ev);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
// Don't do anything with intercepted touch events if
// we are not scrollable
return mScrollable && super.onInterceptTouchEvent(ev);
}
}
在触摸SeekBar
时暂时停止滚动;并在您将手指从 myScrollView.setScrollingEnabled(false)
上抬起时启用它,如下所示
Seekbar