setContentView(R.layout.activity_main); mCamera = getCameraInstance(); context = getApplicationContext(); // Create our Preview view and set it as the content of our activity. mPreview = new CameraPreview(this, mCamera); FrameLayout preview1 = (FrameLayout)findViewById(R.id.camera_preview1); FrameLayout preview2 = (FrameLayout)findViewById(R.id.camera_preview2); //preview.setRotation(-90); preview1.addView(mPreview); preview2.addView(mPreview);
这是我试图做的。在上面的片段中,如果我只使用一个 FrameLayout,它运行正常。就像这样:
mPreview = new CameraPreview(this, mCamera); FrameLayout preview = (FrameLayout) findViewById(R.id.camera_preview); //preview.setRotation(-90); preview1.addView(mPreview);
相应地,布局如下:
<FrameLayout android:id="@+id/camera_preview1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> </FrameLayout> <FrameLayout android:id="@+id/camera_preview2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> </FrameLayout> <LinearLayout android:id="@+id/speedBackgound" android:layout_width="fill_parent" android:layout_height="80dp" android:layout_gravity="bottom" android:orientation="horizontal" > <ImageView android:id="@+id/lastPic" android:layout_width="70dp" android:layout_height="70dp" android:layout_gravity="center" android:layout_marginLeft="10dp" android:layout_weight="1" /> <Button android:layout_marginLeft="10dp" android:id="@+id/button_capture" android:layout_width="80dp" android:layout_height="80dp" android:onClick="takePhoto" android:layout_gravity="right"/> </LinearLayout>
如果是单帧,它可以正常工作。当两帧和预览时 添加我收到运行时错误:
The specified child already has a parent. You must call removeView() on the child's parent first.
有任何解决问题的想法吗?
答案 0 :(得分:0)
您必须创建多个SurfaceTexture
并在createCaptureSession
对象的Camera
方法中传递它们。