title: Getting null pointer exception when using getLayoutParams()
body: <p>I have a custom ImageView class (I don't think the code in the class matters but I'll include it here anyway incase it is needed):</p>
  
  <pre><code>    package com.example.vroy.customcirclebuttontest;
  
  import android.content.Context;
  import android.graphics.Canvas;
  import android.util.AttributeSet;
  import android.util.Log;
  import android.widget.ImageView;
  
  public class CircleButton extends ImageView {`
  
  private  int radius;
  private  int x;
  private  int y;
  
  public CircleButton(Context context) {
      super(context);
      constructorTask();
  }
  
  public CircleButton(Context context, AttributeSet attrs) {
      super(context, attrs);
      constructorTask();
  }
  
  public CircleButton(Context context, AttributeSet attrs, int defStyleAttr) {
      super(context, attrs, defStyleAttr);
      constructorTask();
  }
  
  public CircleButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
      super(context, attrs, defStyleAttr, defStyleRes);
      constructorTask();
  }
  
  
  private void constructorTask() {
      x = 300;
      y = 300;
      radius = 100;
  }
  
  @Override
  public void setPressed(boolean pressed) {
      super.setPressed(pressed);
      Log.i("Button Logger","Button Pressed");
  }
  
  @Override
  protected  void onDraw(Canvas canvas) {
      super.onDraw(canvas);
      canvas.drawCircle(x, y, radius, GameView.green);
      Log.i("Drawing status", "CircleButton Drawing..." + " " + Integer.toString(this.x) + "," + Integer.toString(this.y));
  }
  
  }
  </code></pre>
  
  <p>I declare a instance of this class in my activity:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      testCircleButton = new CircleButton(getApplicationContext());
      makeFullScreen();
  
     testCircleButton.getLayoutParams().width = 200;
     testCircleButton.getLayoutParams().height = 200;
  
      RelativeLayout screenLayout = (RelativeLayout) findViewById(R.id.screenLayout);
      screenLayout.addView(testCircleButton);
  
      Log.i("Button Status","Adding Button To Layout");
  }
  </code></pre>
  
  <p>However when I do this I get a "null pointer" exception.</p>
  
  <p>How can I fix this?</p>