1

I have RelativeLayout with VideoView and need to move and zoom videoView by gestures.

mAnimationLayout = new RelativeLayout(mContext);
mAnimationLayout.setOnTouchListener(new AnimationListener());
RelativeLayout.LayoutParams lpFill = new RelativeLayout.LayoutParams(
    RelativeLayout.LayoutParams.MATCH_PARENT, 
    RelativeLayout.LayoutParams.MATCH_PARENT
);
mVideoView = new VideoView(mContext);
mVideoView.setVideoURI(mProduct.mAnimationVideos.get(0));
mVideoView.start();
mAnimationLayout.addView(mVideoView, lpFill);

And then I'm trying to make this:

private void moveVideo(float x, float y){

    int left = mVideoView.getLeft() + (int)x;
    int top = mVideoView.getTop() + (int)y;

    //mVideoView.layout(left, top, right, bottom);
    RelativeLayout.LayoutParams lp = (LayoutParams) mVideoView.getLayoutParams();
    lp.setMargins(left, top, 0,0);
    mVideoView.setLayoutParams(lp);
    //mVideoView.invalidate();

}
private void scaleVideo(float scale){

    RelativeLayout.LayoutParams lp = (LayoutParams) mVideoView.getLayoutParams();
    lp.width =(int) (mVideoView.getWidth() * scale);
    lp.height = (int) (mVideoView.getHeight() * scale);
    mVideoView.setLayoutParams(lp);
    //mVideoView.invalidate();

}

Sometimes it moves and scales video, but sometimes - only video background, leaving video itself on its place. And it works very slow.

Serafim Suhenky
  • 2,140
  • 1
  • 15
  • 18

0 Answers0