Note that there are some explanatory texts on larger screens.

plurals
  1. POPlacing one relative layout beside another relative layout programatically
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload