There are 2 views in a FrameLayout:
The content of SurfaceView is drawn using OpenGL in another thread:
I'm trying to make the position of View align with the content of SurfaceView. E.g if I draw a moving square, I want to set the position of View to match the square when it is moving.
But when I try it, the View moves before the content of SurfaceView.
I've tried to replace SurfaceView with a TextureView or a CustomView which uses ImageReader to provide surface to native, but no luck.
Does anyone have an idea how to make it possible?
I was able to do it by using a surface from ImageReader
:
Surface
of ImageReader
Image
from ImageReader.OnImageAvailableListener
Image.getTimestamp()
value, this is nano time when the Image
is created. Compare it with nano time from earlier to get the corresponding position. Update the position and draw the corresponding Image
to the View
.Image
after it is drawn on screen by the Choreographer.FrameCallback
after View.onDraw
.