Reputation: 417
My idea is to have two surfaceViews. One surfaceView which will hold an image (say ImageSurgaceView) and second surface that lie on top of the first one which holds the annotations (say AnnotationSurfaceView) like circle, rectangle etc. Now I have to map these surface views such that the height, width are same and moreover, both the surface view should move on drag i.e share the touch events. To be precise, when I move the image up the annotations should also move up.
Now, I am not sure if this is possible in android. Can any one tell or share some info on this. I don't have any implementation idea to this and hence I don't have any specific code. Moreover, I couldn't find anything similar.
Thanks for helping.
Upvotes: 10
Views: 8202
Reputation: 36289
Yes, this is possible. You can add both SurfaceView
s as children of a FrameLayout
. You will also want to call setZOrderMediaOverlay on one or both of your SufaceView
s in order to specify how they are layered.
Furthermore, this could be a graphic intensive algorithm you are describing. Consider adding the AndroidManifest.xml
application attribute android:hardwareAccelerated="true"
.
Finally, just set up a custom OnTouchListener
to handle drag events. Use MotionEvent.getRawX()
and MotionEvent.getRawY()
to get the touch point, and use this to manipulate the canvases.
Upvotes: 21