title: Change margins programmatically doesn't work as expected
body: <p>I have a GUI where Initially margins of <code>innerLayout</code> are <code>0,10,0,100</code> and in my intention <code>hideinfoarea()</code>  should remove the <code>infoLayout</code> and change the margins in <code>0, 10,0,10</code> and <code>showInfoarea()</code> should restore the initial margins and show infoLayout again.</p>
  
  <p>Unfortunately when I set these margins some Layout become not well shown, for example the title is too close to mainLayout, and a piece of image will be covered by infoLayout when I re-enable it.
  despite in my test with layout editor the margins are perfect.</p>
  
  <p>In adition when I invoke <code>showInfoarea()</code> why the layout margins aren't restored to the original conditions, if I simply reverse the operation of <code>hideInfoarea()</code>?</p>
  
  <p>Here my code</p>
  
  <pre><code> RelativeLayout mainLayout;
      LinearLayout innerLayout;
  
      public void hideInfoarea(){
          mainLayout = (RelativeLayout) findViewById(R.id.mainContainer);
          innerLayout = (LinearLayout) findViewById(R.id.innerLayout);
          mainContainer.removeView(infoLayout);
  
          //adjust margins
          RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) innerLayout.getLayoutParams();  
          params.setMargins(0, 10, 0, 10);
          innerLayout.setLayoutParams(params);
      }
  
  public void showInfoarea(){
          mainLayout = (RelativeLayout) findViewById(R.id.mainContainer);
          innerLayout = (LinearLayout) findViewById(R.id.innerLayout);
          mainContainer.addView(infoLayout);
  
          //adjust margins
          RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) innerLayout.getLayoutParams();  
          params.setMargins(0, 10, 0, 100);
          innerLayout.setLayoutParams(params);
      }
  </code></pre>
  
  <p></p>
  
  <p>Here the XML</p>
  
  <pre><code>   &lt;!-- The main content view --&gt;
      &lt;RelativeLayout
              xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:tools="http://schemas.android.com/tools"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              tools:context=".MainActivity"
              android:padding="5dp"
              android:gravity="fill_horizontal|fill_vertical"
              android:background="@color/Platinum"
              android:id="@+id/mainLayout"&gt;
  
          &lt;TextView
                  android:id="@+id/txtTitle"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_alignParentTop="true"
                  android:layout_centerHorizontal="true"
                  android:text="Sample"
                  android:textSize="12dp"
                  android:layout_marginBottom="10dp"/&gt;
  
          &lt;LinearLayout
                  android:orientation="vertical"
                  android:layout_width="match_parent"
                  android:layout_height="fill_parent"
                  android:id="@+id/innerlayout"
                  android:layout_marginTop="10dp"
                  android:layout_marginBottom="100dp"&gt;
  
              &lt;ImageView
                      android:layout_width="wrap_content"
                      android:layout_height="fill_parent"
                      android:id="@+id/imageView"
                      android:scaleType="fitXY"
                      android:src="@drawable/rectangle"
                      android:layout_marginBottom="100dp"
                      android:layout_marginTop="10dp"/&gt;
          &lt;/LinearLayout&gt;
  
          &lt;LinearLayout
                  android:layout_width="400dp"
                  android:layout_height="100dp"
                  android:layout_alignParentBottom="true"
                  android:background="@drawable/background_label_mm"
                  android:layout_centerHorizontal="true"
                  android:orientation="vertical"
                  android:id="@+id/infoLayout"
                  android:layout_margin="5dp"&gt;
  
          &lt;/LinearLayout&gt;
  
      &lt;/RelativeLayout&gt;
  
  
      &lt;!-- The navigation drawer --&gt;
  
      &lt;ListView
              android:id="@+id/drawer"
              android:layout_width="320dp"
              android:layout_height="match_parent"
              android:layout_gravity="start"
              android:background="#F3F3F4"
              android:choiceMode="singleChoice"
              android:divider="@android:color/transparent"
              android:dividerHeight="0dp"/&gt;
  
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>