title: Getting screen width Android in dips
body: <p>I want to get the screen width , and set it to my layout which is a child of a Horizontal Scroll View . I am doing this but it makes my layout wider than I want . </p>
  
  <p>padding is defined with dips. </p>
  
  <pre><code>    Display display = getWindowManager().getDefaultDisplay();
      DisplayMetrics outMetrics = new DisplayMetrics ();
      display.getMetrics(outMetrics);
  
      float density  = getResources().getDisplayMetrics().density;    
      int padding = getResources().getDimensionPixelSize(R.dimen.padding); 
      layoutWidth = (int) ((outMetrics.widthPixels * density) - 2*padding);
  </code></pre>