相互显示两个表面视图?

时间:2021-01-18 11:58:29

Is there any way to set two surface views over each other so that, one of them to hold a CameraPreview and the other to hold OpenGL surface.

有没有办法在彼此之间设置两个表面视图,以便其中一个用于保持CameraPreview而另一个用于保持OpenGL表面。

I have attempted this problem and my attempts are mentioned below in (code1 and code2)

我尝试过这个问题,我的尝试在下面提到(code1和code2)

Code 1 1- in this code, I open the camera with command mentioned in line 1 2- instantiated an object from the Render Class, and add this object to the surfaceView using setContentView()

代码1 1-在这段代码中,我用第1行中提到的命令打开摄像机2-从渲染类中实例化一个对象,并使用setContentView()将此对象添加到surfaceView

but in this case, tha camera opens for few seconds and disaappears, then , the OpenGl object appearas.

但在这种情况下,相机会打开几秒钟然后消失,然后是OpenGl对象的上传。

public void surfaceCreated(SurfaceHolder holder) {

    camera = android.hardware.Camera.open(); //line 1
    //gLSurfaceView = new GLSurfaceView(this);
    //gLSurfaceView.setRenderer(new MyRender());
    //setContentView(gLSurfaceView);
}

Code 2 In this code, I instantiate both of the CameraSurface and the Render Class. and I also created a FrameLayout in the XML file. Then the camerSurface object is added to setContentView and the Render object to the FrameLayout. but this way, causes only the object added to the framelayout to be displayed.

代码2在此代码中,我实例化了CameraSurface和Render类。我还在XML文件中创建了一个FrameLayout。然后将camerSurface对象添加到setContentView,将Render对象添加到FrameLayout。但这样,只会显示添加到framelayout的对象。

cameraSurfacePreviewDemo = new CameraSurfacePreviewDemo(this);
    glSurfaceView = new GLSurfaceView(this);
    glSurfaceView.setRenderer(new MyRender());
    //setContentView(cameraSurfacePreviewDemo);
    //setContentView(glSurfaceView);
    //fl01.addView(glSurfaceView);
    //fl01.addView(cameraSurfacePreviewDemo);

=========================================================================================== Any provision with good tutorials for beginners in Android Camera and AndR "Augmented Reality" Or suggesting good books for both beginners in Android Camera and AndR "Augmented Reality will be highly appreciated.

================================================== =========================================任何为Android初学者提供优秀教程的条款相机和AndR“增强现实”或为Android Camera和AndR“增强现实”的初学者推荐好书将受到高度赞赏。

1 个解决方案

#1


0  

IIRC it is impossible. Surface Views can not overlap. (There was longer explanation from Diane Hackeborn)

IIRC是不可能的。曲面视图不能重叠。 (Diane Hackeborn有更长的解释)

#1


0  

IIRC it is impossible. Surface Views can not overlap. (There was longer explanation from Diane Hackeborn)

IIRC是不可能的。曲面视图不能重叠。 (Diane Hackeborn有更长的解释)