在 SeekBar 的容器中,创建并应用(到 seekBar)一个 OnTouchListener,如下所示:
private final OnTouchListener onTouchListener = new OnTouchListener()
{
public boolean onTouch(View v, MotionEvent event)
{
// If the View in question isn't a child of the seekBar and
// isn't the seekBar itself, then return and don't consume the event.
if ( (seekBar.findViewById(v.getId()) == null) &&
(v.getId() != seekBar.getId()) )
{
return false;
}
// The View is either a child of the seekBar or is the seekBar itself,
// so we pass the event along to the seekBar and return true, signifying
// that the event has been consumed.
seekBar.onTouchEvent(event);
return true;
}
}
试试这个,看看它是否有效;您可能需要为 if 语句创建更稳健的条件。