Placing one relative layout beside another relative layout programatically
<p>I have two relative layouts that are currently displayed one below the other. I want the second layout to be displayed to right of the first relative layout programatically.</p>

<p>following is the code i used.</p>

<p>main.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" &gt;
    &lt;RelativeLayout 
         android:layout_width="620dp"
         android:layout_height="wrap_content"
         android:orientation="vertical"
         android:id="@+id/lay1" &gt;    
         &lt;TextView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="@string/hello1" /&gt;
    &lt;/RelativeLayout&gt;
    &lt;RelativeLayout 
         android:layout_width="620dp"
         android:layout_height="wrap_content"
         android:orientation="vertical" 
         android:id="@+id/lay2"&gt;  
         &lt;TextView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="@string/hello2" /&gt;
    &lt;/RelativeLayout&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>myAct.java</p>

<pre><code>public class myAct extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        LinearLayout layoutContainer = new LinearLayout(this);
        layoutContainer.setLayoutParams(new     LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

        // Arguments here: width, height, weight 
        LinearLayout.LayoutParams childLp = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1);
        RelativeLayout layoutLeft = new RelativeLayout(this);

        layoutContainer.addView(layoutLeft, childLp);
        RelativeLayout layoutRight = new RelativeLayout(this);
        layoutContainer.addView(layoutRight, childLp);
     }
}
</code></pre>

<p>Thanks in advance</p>
