title: How to find the height and width of screen in android
body: <p>I have a class called crate where i would like to find the height and width. to do this I am using: </p>
  
  <pre><code>public class Crate {
      public int acrossCrate;
      public int upDownCrate;
  
      public Crate(Context context) {
  
      DisplayMetrics metrics = context.getResources().getDisplayMetrics();
      int width = metrics.widthPixels;
      int height = metrics.heightPixels;
  }
  }
  </code></pre>
  
  <p>But I have another class called draw which calls the crate class, and when i use the Context context in crate it gives an error when calling it in the draw class:</p>
  
  <pre><code>public class Draw extends View {
      float x, y;
      Paint red = new Paint();
      Paint green = new Paint();
      Paint black = new Paint();
      Paint blue = new Paint();
      Bitmap player;
      Bitmap crate;
      int rectSide = 1000;
  
      Player thePlayer = new Player();
      Crate theCrate = new Crate();//&lt;-- ERROR when i use Context context
  </code></pre>
  
  <p>Im really stuck and if anyone knows how to do this and could help me that would be great. </p>