//seekbarLayout 是seekBar对象statusSeekbar的父层布局 seekbarLayout = mStatusViewLayout.findViewById(R.id.id_seekbar_layout); seekbarLayout.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { Rect seekRect = new Rect(); statusSeekbar.getHitRect(seekRect); if ((event.getY() >= (seekRect.top - 500)) && (event.getY() <= (seekRect.bottom + 500))) { float y = seekRect.top + seekRect.height() / 2; //seekBar only accept relative x float x = event.getX() - seekRect.left; if (x < 0) { x = 0; } else if (x > seekRect.width()) { x = seekRect.width(); } MotionEvent me = MotionEvent.obtain(event.getDownTime(), event.getEventTime(), event.getAction(), x, y, event.getMetaState()); return statusSeekbar.onTouchEvent(me); } return false; } });
原理:给一个大一点面积的View 获取触摸事件,直接手动调用seekbar onTouchEvent.