android drawing rectangle on videoview and getting the co-ordinates

525 views Asked by At

The app I'm developing is live streaming on android VideoView. One of the features I like to add is drawing rectangle on the VideoView using touch and once I release the touch, I should get the rectangle properties like x-y co-ordinates,its height and width. Please help.

Thanks in advance

1

There are 1 answers

1
jDur On BEST ANSWER

Ok, there is a little information to work with, but at high level I would do something like this:

  • Put your VideoView inside of a RelativeLayout or maybe a FrameLayout
  • Put in the same layout, and over the VideoView, another View where you will draw your rectangle. You cand make this just defining the view in the layout behind of the VideoView declaration.

  • Draw the rectangle in the View (This view could be a ImageView where you load a shape from your drawable folder, or maybe another Relative or Frame layout where you place some other Views, rectangles? )

  • Just capture onTouchEvents for the View to determine when you should draw the rectangle or when you should recover rectangle dimensions.