Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid layout: How to put this ViewGroup inside a RelativeLayout?
    text
    copied!<p>Hi how to make this code works? I want this class CameraSurfaceView to put inside a relative layout?</p> <p>Code: </p> <pre><code>public class CameraSurfaceView extends ViewGroup implements SurfaceHolder.Callback{ private final String TAG = "Preview"; private SurfaceView mSurfaceView; private SurfaceHolder mHolder; private Size mPreviewSize; private List&lt;Size&gt; mSupportedPreviewSizes; private Camera mCamera; public CameraSurfaceView(Context context) { super(context); mSurfaceView = new SurfaceView(context); addView(mSurfaceView); mHolder = mSurfaceView.getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } ... } </code></pre> <p>MainActivity;</p> <pre><code>public class MainActivity extends Activity{ RelativeLayout rlCamWrapper; CameraSurfaceView cameraSurfaceView; private SurfaceView surfaceView; private boolean isRecording = false; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Hide the window title. requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); cameraSurfaceView = new CameraSurfaceView(this); setContentView(R.layout.main); } ... } </code></pre> <p>xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/relativeLayout1" android:orientation="horizontal" android:weightSum="1.0" &gt; &lt;VideoView android:id="@+id/videoView1" android:layout_alignParentTop="true" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight=".5"/&gt; &lt;RelativeLayout android:id="@+id/surfaceViewWrapper" android:layout_alignParentTop="true" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight=".5"&gt; &lt;SurfaceView android:id="@+id/surfaceView2" android:layout_alignParentTop="true" android:layout_height="fill_parent" android:layout_width="fill_parent" /&gt; &lt;/RelativeLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>thanks ahead for your help guys.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload