title: applying setLayoutParams on a button programmatically causes the whole layout to get mixed and abnormal
body: <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="wrap_content"
  android:layout_height="match_parent" &gt;
  
  &lt;LinearLayout
      android:id="@+id/buttons"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_alignParentLeft="true" &gt;
  
      &lt;Button
          android:id="@+id/insertButtonVIEW"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:text="insert" /&gt;
  
      &lt;Button
          android:id="@+id/removeButtonVIEW"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:text="remove" /&gt;
  &lt;/LinearLayout&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Sometimes, depending on a situaiton, I am hiding removeButtonVIEW using the method <code>setVisibility(View.INVISIBLE);</code>
  When that happens, I want to my insertButtonVIEW to take the whole width of the screen (when the two are present, each one takes 50% of the screen).</p>
  
  <p>Since this might or might not happen, I am doing these changes programmatically.</p>
  
  <p>I tried the following methd which worked, however, it is causing for all the interface to go jumbo mumbo, as everything's location on the screen is getting mixed.</p>
  
  <pre><code>modifyButton.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
  </code></pre>
  
  <p>Any hints ?</p>
  
  <p>UPDATE 1 after applying the answer : 
  I am using the following code to set the button to invisible.</p>
  
  <pre><code>Bundle extras;
  extras = getIntent().getExtras();
  String answer = extras.getString("answer");
  
  if(answer.equalsIgnoreCase("yes")
  {
    insertButton.setEnabled(true);
    insertButton.setText("INSERT");
    removeButton.setVisibility(View.INVISIBLE);
  }
  else
  {
   //whatever
  }
  </code></pre>