title: How to calculate dp from pixels in android programmatically
body: <p>I want to calculate <code>dp</code> from <code>px</code> programmatically. How to do it?
  I get resolution from:</p>
  
  <pre><code>DisplayMetrics displaymetrics = new DisplayMetrics();
  getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
  ht = displaymetrics.heightPixels;
  wt = displaymetrics.widthPixels;
  </code></pre>