Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>simply changing <code>&lt;SurfaceView</code> in your xml with <code>&lt;your.package.CameraSurfaceView</code> should do the trick. Then just get it with <code>findViewById()</code> in your code</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); setContentView(R.layout.main); // this is the important part cameraSurfaceView = (CameraSurfaceView) findViewById(R.id.surfaceView2); } ... } </code></pre> <p>also, make sure you overload the other constructors for your view (something like this):</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); } public CameraSurfaceView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); ... } public CameraSurfaceView(Context context, AttributeSet attrs) { super(context, attrs); ... } ... } </code></pre>
 

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