问题描述
是否可以仅在移动拇指时使搜索栏移动.现在,即使在手指触摸时,搜寻栏也会移动可进度绘制.我们如何禁用搜寻栏的移动手指触摸进度图?
Is it possible to have the seekbar move only when the thumb is moved.Right now the seekbar moves even on finger touch in theprogressdrawable. How do we disable the movement of the seekbar onfinger touch of the progressdrawable?
谢谢.
推荐答案
覆盖 OnTouchListener
用于搜寻栏,并且仅在MotionEvent
是移动事件时处理拇指上的移动.
Override the OnTouchListener
for the seekbar and only process the movement on the thumb when the MotionEvent
is a move event.
event.getAction() == MotionEvent.ACTION_MOVE
更新:1
类似的事情会起作用,但是要注意的是,即使用户将拇指移动了2个单位,搜索栏也会移动.而且您真的不应该停止这种行为,因为它会破坏搜索栏.
Something like this will work but the catch is that even if the user moves the thumb 2 units the seekbar moves. And you should really not stop this behavior as it would mess the the seekbar.
seekBar.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_MOVE){
Log.d(TAG, "Moved , process data, Moved to :" + seekBar.getProgress());
seekBar.setProgress(seekBar.getProgress());
return false;
}
Log.d(TAG, "Touched , Progress :" + seekBar.getProgress());
return true;
}
});
这篇关于Android seekbar解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!