title: displaying custom surfaceview in main.xml
body: <p>i have a custom surfaceview which i need to add into my current main.xml layout. this surfaceview is used to stream camera liveview. i having issues making this work.</p>
  
  <p>i have no issue if i run the code as </p>
  
  <pre><code>     cameraPreview = new HttpCameraPreview(this, null, viewWidth, viewHeight);
  setContentView(cameraPreview);
  </code></pre>
  
  <p>however, i do not want my custom surfaceview to be the main view. i want it to be a surfaceview inside my main.xml. </p>
  
  <p>hope to get some suggestions/advises. i tried refering to this link, but no help too.
  <a href="https://stackoverflow.com/questions/5203547/draw-surfaceview-from-layout-xml">Draw SurfaceView from layout xml</a></p>
  
  <p>thanks!</p>
  
  <p>part of the main.xml as below:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"&gt;
                      &lt;ImageView
                 android:id="@+id/preview_image_view"
                 android:layout_height="wrap_content"
                 android:layout_weight="3.0"
                     android:layout_width="fill_parent"
                 /&gt;
  &lt;SurfaceView Class ="org.saboteur.nikonshooter.HttpCameraPreview"
  android:layout_width="fill_parent" 
  android:id="@+id/surface_preview" 
  android:layout_height="10dip" 
  android:layout_weight="3"/&gt;
  </code></pre>
  
  <p>my custom surfaceview class partial code look like this:</p>
  
  <pre><code>  public class HttpCameraPreview extends SurfaceView implements SurfaceHolder.Callback {
      private static final String TAG = "test";
      private static final String url = "http://bijint.com/jp/tokei_images/0022.jpg";
      private CanvasThread canvasThread;
  
      private SurfaceHolder holder;
      private HttpCamera camera;
  
      private HttpCameraPreview mSurfaceView;
  
      private int viewWidth;
      private int viewHeight;
  
      public HttpCameraPreview(Context context, AttributeSet attributeSet, int viewWidth, int viewHeight) {
          super(context, attributeSet);
          Log.e("HttpCameraPreview", "inside HttpCameraPreview()");
          Log.e("HttpCameraPreview", "create surface view to r.id");
  
  
          try{
          holder = getHolder();
          holder.addCallback(this);
          holder.setType(SurfaceHolder.SURFACE_TYPE_NORMAL);
          this.viewWidth = viewWidth;
          this.viewHeight = viewHeight;
          canvasThread = new CanvasThread();
          catch (Exception e){
              Log.e("HttpCameraPreview", "---&gt;Exception = "+e);
          }
      }
  </code></pre>