title: Android - canvas onDraw does not fire
body: <p>I am trying to add a canvas view to a relative layout inside a horizontal scroll view.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:background="#fff"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
  &gt;
      &lt;HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/hsv"
          android:layout_width="fill_parent"
          android:background="#EEDB00"
          android:layout_height="30mm"&gt;
  
          &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/canvas"
              android:background="#000"
              android:layout_width="300mm"
              android:layout_height="20mm"&gt;
          &lt;/RelativeLayout&gt;
  
      &lt;/HorizontalScrollView&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>I created a class called CanvasView which extends View, and I drew some basic shapes by over-riding onDraw(). However the canvas does not appear in the relativelayout, when I do:</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
          cView = new CanvasView(this);
          rLayout = (RelativeLayout)this.findViewById(R.id.canvas);
          rLayout.addView(cView);
      }
  </code></pre>
  
  <p>However, when I directly add it by calling <code>setContentView(cView);</code> it works. On digging, I found that when I call <code>addView()</code>, the <code>onDraw()</code> is not firing at all, and hence the canvas is not drawn... Any ideas on how to fix this?</p>