title: Android: Put two elements in the center of relativeLayout programmatically
body: <p>I add two elements in the view for code. An imageView and a Spinning Wheel. The two elements shown but in the same place. And I desire to put the ImageView above the other element, in the center of screen.</p>
  
  <p>The code that add the views:</p>
  
  <pre><code>    RelativeLayout container= (RelativeLayout)findViewById(R.id.container);
  
      RelativeLayout.LayoutParams position = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      position.addRule(RelativeLayout.CENTER_IN_PARENT);
      imgCenter.setLayoutParams(position);
      container.addView(imgCenter); 
  
      RelativeLayout.LayoutParams position2 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      position2.addRule(RelativeLayout.CENTER_IN_PARENT);
      position2.addRule(RelativeLayout.BELOW,imgCenter.getId());
      spinner.setLayoutParams(position2);
      container.addView(spinner);
  </code></pre>
  
  <p>The xml of relativelayout:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context="com.app.exemple.LoadingActivity"
  android:id="@+id/container" &gt;
  </code></pre>
  
  <p></p>