title: Android drawing on surfaceview and canvas
body: <p>I have a "simple" problem. I try to draw on surfaceview. Layout-XML:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:keepScreenOn="true"
      android:orientation="vertical" &gt;
  
      &lt;TextView
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:text="@string/hello" /&gt;
  
      &lt;SurfaceView
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/imagesurface"
          android:layout_height="fill_parent"
          android:layout_width="fill_parent"
          android:background="#00ff00"&gt;
      &lt;/SurfaceView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The Activity is a SurfaceHolder.Callback:</p>
  
  <pre><code>public class OpenCvonAndroidGTDforHOGActivity extends Activity implements SurfaceHolder.Callback{
  
      private SurfaceHolder _surfaceHolder;
      private SurfaceView _surfaceView;
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          _surfaceView = (SurfaceView)findViewById(R.id.imagesurface);
          _surfaceHolder = _surfaceView.getHolder();
          _surfaceHolder.addCallback(this);
          _surfaceView.setWillNotDraw(false);
  
      }
  
      protected void onDraw(Canvas canvas) {
          canvas.drawRGB(255, 0, 255);            
      }
  
      public void surfaceCreated(SurfaceHolder holder) {
          Canvas canvas = null;
          try {
              canvas = holder.lockCanvas();
              synchronized(holder) {
                  onDraw(canvas);
              }
          } catch (Exception e) {
              e.printStackTrace();
          } finally {
              if (canvas != null) {
                  holder.unlockCanvasAndPost(canvas);
              }
          }
      }
  
  
      public void showToast(String msg) {
          Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show();
      }
  }
  </code></pre>
  
  <p>If i call </p>
  
  <p><code>_surfaceview.setBackground(Color.RED)</code>
  in onDraw(...) it works. But </p>
  
  <p><code>canvas.drawRGB(255, 0, 255)</code> 
  doesn't work :(</p>