title: How to determine the screen width in terms of dp or dip at runtime in Android?
body: <p>I need to code the layout of the android widgets using dip/dp (in java files). At runtime if I code,<br><br>
      <code>int pixel=this.getWindowManager().getDefaultDisplay().getWidth()</code>;</p>
  
  <p>this return the screen width in pixels (px). To convert this to dp, I coded:<br><br>
              <code>int dp =pixel/(int)getResources().getDisplayMetrics().density ;</code><br><br>
  This does not seem to be returning correct answer. I made the emulator of WVGA800 whose screen resolution is 480 by 800. When the run the emulator and let the code print the values of pixel and dp, it came to 320 in both. This emulator is 240 dpi whose scale factor would be 0.75. </p>