0

I try to VideoView follow the finger. I write the same code which works fine with ImageView but it doesn't work with 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;
}
Nikolas Charalambidis
  • 40,893
  • 16
  • 117
  • 183

0 Answers0