Я пытаюсь, чтобы VideoView следил за пальцем.Я пишу тот же код, который отлично работает с ImageView, но он не работает с VideoView.
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
final int Y = (int) motionEvent.getRawY();
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN: // A pressed gesture has started
y1 = view.getY();
yDelta = Y - layoutParams.topMargin;
originalTopMargin = layoutParams.topMargin;
break;
case MotionEvent.ACTION_UP:
layoutParams.topMargin = originalTopMargin;
layoutParams.bottomMargin = 0;
view.setLayoutParams(layoutParams);
break;
case MotionEvent.ACTION_MOVE:
layoutParams.topMargin = Y - yDelta;
layoutParams.bottomMargin = -(Y - yDelta);
float y2 = view.getY();
float deY = y2 - y1;
if(Math.abs(deY) > MIN_DISTANCE){
finish();
}
view.setLayoutParams(layoutParams);
break;
}
return false;
}