title: Can't update an ImageView on top of a (camera) SurfaceView
body: <p>In my Android app there is an Activity showing a Camera preview, implemented as a SurfaceView using the documentation here: <a href="http://developer.android.com/guide/topics/media/camera.html#custom-camera" rel="nofollow">http://developer.android.com/guide/topics/media/camera.html#custom-camera</a>.  </p>
  
  <p>I want to show an ImageView on top of this SurfaceView from the start, but I also want to update its layout (width, height and source image) when the user takes a first photo.
  My problem is that the code works in the first step, the image is shown over the SurfaceView when the Activity starts, but its layout doesn't change when I want to.</p>
  
  <p>Here is the XML:</p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/layout_capture"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".CaptureActivity" &gt;
  
      &lt;RelativeLayout
          android:id="@+id/camera_preview"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center"
      &gt;
              &lt;!-- Here I will programmatically add the SurfaceView --&gt;
  
          &lt;ImageView
              android:id="@+id/image_picture"
              android:layout_width="100dp"
              android:layout_height="80dp"
              android:layout_centerInParent="true"
              android:contentDescription="picture preview"
              android:src="@drawable/image1" /&gt;
  
      &lt;/RelativeLayout&gt;
  
      &lt;Button
        android:id="@+id/button_capture"
        android:text="Capture"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|center"
      /&gt;
  
  
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>The SurfaceView is added with this snippet:</p>
  
  <pre><code>mPreview = new CameraPreview(this, mCamera);
  RelativeLayout preview = (RelativeLayout) findViewById(R.id.camera_preview);
  preview.addView(mPreview, 0); //
  </code></pre>
  
  <p>This is the code that should update the ImageView (it's inside the <code>onPictureTaken()</code> method)... but it doesn't work:</p>
  
  <pre><code>LayoutInflater linf = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  FrameLayout frame = (FrameLayout) linf.inflate(R.layout.activity_capture, null);
  ImageView imgw = (ImageView) frame.findViewById(R.id.image_left_picture); // get the ImageView
  
  imgw.setImageResource(R.drawable.image2); // change its source image        
  imgw.setLayoutParams(new RelativeLayout.LayoutParams(w, h)); //change its size
  
  invalidate(); // also tried to add this method call... nothing changes.
  </code></pre>