2016-08-18 4 views
0
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:Wie können mehrere Kameravorschauen in einer Aktivität angezeigt werden?

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.

Irgendwelche Ideen, um das Problem zu lösen?

+0

Hey @androxpa Sie erreichte Lösung Ihres Problems .. wenn ja dann Bitte helfen Sie mir..mein Frage ist hier ......... http: //stackoverflow.com/questions/41392791/how-to -apply-custom-filters-in-a-camera-oberflächenansicht-preview –

Antwort

0

Sie müssen mehrere SurfaceTexture erstellen und sie in der Methode createCaptureSession von Camera Objekt übergeben.

+0

Hey @Omar Aflak..Bitte sagen Sie mir, wenn Sie die Lösung kennen.Klicken Sie auf jede Art von Hilfe geschätzt ... meine Frage ist hier, wenn Sie wirklich wissen dann sagen Sie mir ... Bitte ...... http: //stackoverflow.com/questions/41392791/how-to-apply-custom-filters-in-a-cameras-surfaceview-preview –

Verwandte Themen