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);
This is what I have tried to do. In above snippet if I use just one FrameLayout , it works fine.Like this:1つのアクティビティで複数のカメラプレビューを表示するにはどうすればよいですか?
mPreview = new CameraPreview(this, mCamera); FrameLayout preview = (FrameLayout) findViewById(R.id.camera_preview); //preview.setRotation(-90); preview1.addView(mPreview);
Correspondingly, the layout looks like this:
<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>
In case of single frame, it works fine. When two frames and previews are added I get a runtime error:
The specified child already has a parent. You must call removeView() on the child's parent first.
問題を解決するための方法はありますか?
あなたはあなたの問題の解決策を得ました。もしそうなら、私に助けてください。私の質問はここに......... http://stackoverflow.com/questions/41392791/how-to -apply-custom-filters-in-a-camera-surfaceview-preview –