title: getWidth and getHeight are returning a zero
body: <p>I am trying to make a simple drawing program for the android.</p>
  
  <p>I have a custom <code>View</code> class to handle the drawing. When I call its <code>getWidth</code> and <code>getHeight</code> metheds, I get a zero.</p>
  
  <p>But, the drawing works fine, I hard code in the width and height so it works.  Why is it doing this?</p>
  
  <hr>
  
  <p><strong>My View class</strong></p>
  
  <pre><code>public class cDrawing extends View{
  
      char BitMap[];
      static final short WIDTH=160;
      static final short HEIGHT=440;
      static final char EMPTY=' ';
      int mWidthSize;
      int mHeightSize;
  
      static final char RED ='R';
      int y;
  
      public cDrawing(Context context) {
          super(context);
  
          y=3;
          // set up our bitmap
          BitMap=new char[WIDTH*HEIGHT];
          for(int i=0; i&lt;WIDTH*HEIGHT; i++)
                  BitMap[i]=EMPTY;
  
  
          // returns zero why???????
          int h=getHeight();
          h=400;
          int w=getWidth();
          w=320;
          mWidthSize=w/WIDTH;
          mHeightSize=h/HEIGHT;
  
  
          // TODO Auto-generated constructor stub
      }
  </code></pre>
  
  <hr>
  
  <p><strong>The Activity class</strong></p>
  
  <pre><code>public class cCanves extends Activity  implements OnClickListener {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.canves);
          cDrawing board=new cDrawing(this);
  
  
          LinearLayout layout = (LinearLayout)findViewById(R.id.parent2);
          layout.addView(board);
  
  
          // set up buttons
          View mEraser = findViewById(R.id.buteraser);
          mEraser.setOnClickListener(this);
  
          View mBlack = findViewById(R.id.butblack);
          mBlack.setOnClickListener(this);
  
          View mWhite = findViewById(R.id.butwhite);
          mWhite.setOnClickListener(this);
  
          View mRed = findViewById(R.id.butred);
          mRed.setOnClickListener(this);
  
      } // end function
  
      public void onClick(View v) {
          Intent i;
          switch(v.getId())
          {
          case R.id.buteraser:
              break;
          case R.id.butblack:
              break;
          case R.id.butwhite:
              break;
          case R.id.butred:
              break;
          } // end switch
  
      }   // function
  }
  </code></pre>
  
  <hr>
  
  <p><strong>the xml file</strong> </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout android:id="@+id/parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:orientation="vertical"
    android:layout_height="fill_parent"&gt;
  
      &lt;LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:orientation="horizontal"
        android:layout_height="wrap_content"&gt;
  
      &lt;ImageButton android:id="@+id/buteraser"
        android:src="@drawable/icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/&gt;
  
      &lt;ImageButton android:id="@+id/butblack"
        android:src="@drawable/icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/&gt;
  
      &lt;ImageButton android:id="@+id/butwhite"
        android:src="@drawable/icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/&gt;
  
      &lt;ImageButton android:id="@+id/butred"
        android:src="@drawable/icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/&gt;
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout android:id="@+id/parent2"
        android:layout_width="fill_parent"
        android:orientation="vertical"
        android:layout_height="fill_parent"&gt;
      &lt;/LinearLayout&gt;
  
  
  &lt;/LinearLayout&gt;
  </code></pre>