title: Programatically position ImageView in the center of the screen
body: <p>I would like to programatically position ImageView in the center of the screen.
  In xml, ImageView is positioned in top left corner. I tried to do it in xml, but it was not possible due to some reasons.
  ImageView width is 200dp, and height is 220dp.</p>
  
  <p>This is what I have for now:</p>
  
  <pre><code>        DisplayMetrics dm = getApplicationContext().getResources().getDisplayMetrics();
          float dpHeight = dm.heightPixels / dm.density;
          float dpWidth = dm.widthPixels / dm.density;
  
          RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) imageView.getLayoutParams();
          lp.leftMargin = lp.leftMargin + (int) ((dpWidth / 2) - 100);
          lp.topMargin = lp.topMargin + (int) ((dpHeight / 2) - 110);
  </code></pre>