Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your primary LinearLayout is set to Horizontal so the first 5 text view and the layout2 are shown on the same line. Adding Layout3 to Layout2 makes the Layout3 to be shown from the right of the last text view from primary Linear Layout. On a 10 inch tablet i see only the first 2 elements of your LinearLayout. Perhaps on a smaller screen you don't see them. Try using </p> <pre><code>text.setLayoutParams(new LayoutParams(50, LayoutParams.WRAP_CONTENT)); </code></pre> <p>instead of</p> <pre><code>text.setLayoutParams(new LayoutParams(155, LaoutParams.WRAP_CONTENT)); </code></pre> <p>and you should see all your text views.</p> <p><strong>EDIT :</strong> In your case this should do the trick; 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="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;ScrollView android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;LinearLayout android:id="@+id/dyn_layout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="10dip" &gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:id="@+id/dyn_layout2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:visibility="gone" android:padding="10dip" &gt; &lt;/LinearLayout&gt; &lt;/ScrollView&gt; &lt;Button android:id="@+id/dyn_button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Add TextViews" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>and code :</p> <pre><code>@Override public void onClick(View v) { switch (v.getId()) { case R.id.dyn_button1: LinearLayout layout = (LinearLayout) findViewById(R.id.dyn_layout); LinearLayout layout2 = (LinearLayout) findViewById(R.id.dyn_layout2); LinearLayout layout3 = null; for (int i = 0; i &lt; 10; i++) { if (i &gt; 4) { if (i == 5) { layout2.setPadding(10, 60, 10, 10); layout3 = new LinearLayout(this); layout3.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); layout3.setOrientation(LinearLayout.HORIZONTAL); layout3.setPadding(10, 10, 10, 10); } System.out.println("**** Adding text view " + i); TextView text = new TextView(this); text.setText("The Value of i is :" + i); text.setTextSize(12); text.setGravity(Gravity.LEFT); text.setLayoutParams(new LayoutParams(155, LayoutParams.WRAP_CONTENT)); layout3.addView(text); if (i == 9) { System.out .println("Added second linear layout to first"); layout2.setVisibility(View.VISIBLE); layout2.addView(layout3); } } else { System.out.println("###### Adding text view " + i); TextView text = new TextView(this); text.setText("The Value of i is :" + i); text.setTextSize(12); text.setGravity(Gravity.LEFT); text.setLayoutParams(new LayoutParams(155, LayoutParams.WRAP_CONTENT)); layout.addView(text); } } } } </code></pre>
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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