title: Using layoutparams in relativeLayout with dp
body: <p>I m making an app and i want to be able to move a view using its margins dynamically.
  I tried using this :</p>
  
  <pre><code>RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)cover.getLayoutParams();
  params.leftMargin= 470;
  params.topMargin= 20;
  cover.setLayoutParams(params); (cover is an ImageView)
  </code></pre>
  
  <p>The problem with this code its that it uses px instead of dp. I also tried using DisplayMetrics to convert my px values to dp but failed . Can you help me ?</p>