Creating nested Linear layout dynamically with weights to have multiple buttons on same line
<p>I'm trying to create a toggle button that will display more buttons and some <code>TextView</code> like shown below.</p>

<p><a href="https://i.stack.imgur.com/6IjnW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6IjnW.png" alt="enter image description here"></a></p>

<p>With the toggle button ON it will display the <code>TextView</code>s and 3 extra buttons, once switched off it will close those, Rearranging the toggle buttons below it as shown. </p>

<p>The part I specifically need help with is creating the second linear layout and setting weightings for each of my buttons?</p>

<pre><code>Public void toggleswtich(){
                layout = (LinearLayout)  findViewById(R.id.ReportsLayout);
                LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, 100);
                lp.weight = 1;
                Button enterJob = new Button(Reports.this);
                layout.setLayoutParams();
               // if (button.isActivated()) {
                    enterJob.setText("Open");
                    layout.setWeightSum(1);
                    layout.addView(enterJob);


                    enterJob.setOnClickListener(OnClickOpenComp(enterJob));
               // }
               // else {
                    enterJob.setText("Clsoe");
                    layout.addView(enterJob);

                    enterJob.setOnClickListener(OnClickOpenComp(enterJob));
                      //}
                 }
</code></pre>

<p>As requested this is my xml, however there isnt much to show as everything is created with code in run time once a Job is saved.</p>

<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_height="match_parent"
android:padding="10dp"
android:layout_width="match_parent"&gt;

&lt;TextView
    android:textSize="40dp"
    android:layout_width="wrap_content"
    android:text="Username"
    android:layout_height="wrap_content" /&gt;

&lt;EditText
    android:textSize="40dp"
    android:id="@+id/etUsername"
    android:layout_width="match_parent"
    android:layout_marginBottom="10dp"
    android:layout_height="wrap_content" /&gt;


&lt;ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clickable="false"
    android:nestedScrollingEnabled="false"&gt;

    &lt;LinearLayout
        android:id="@+id/ReportsLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"&gt;
    &lt;Button
        android:textSize="40dp"
        android:id="@+id/bEmptyJN"
        android:text="Enter Job number"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" /&gt;
    &lt;/LinearLayout&gt;
&lt;/ScrollView&gt;

&lt;requestFocus
    android:layout_gravity="right"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" /&gt;
</code></pre>

<p></p>

<p>Here's what it looks like with jobs, picture the jobs as toggle buttons</p>

<p><a href="https://i.stack.imgur.com/0evNn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0evNn.png" alt="What I&#39;ve accomplished"></a></p>

<p>Let me know if you'd like anymore information</p>