title: RelativeLayout refresh after view.setVisibility(View.GONE) and view.setVisibility(View.VISIBLE)
body: <p>Please look at the following image to understand the problem:</p>
  
  <p><img src="https://i.stack.imgur.com/YZjOF.png" alt="enter image description here"></p>
  
  <p>As you can see, there is a <code>RelativeLayout</code> which holds a custom <code>View</code> and a <code>LinearLayout</code>.<BR>
  Between them, there is also another <code>View</code>, which <code>Visibility</code> is set to <code>GONE</code>.
  Now, when I press the <code>Button</code>, I would like to change the visibility of that <code>GONE</code> View to <code>VISIBLE</code>, and rearrange the <code>RelativeLayout</code>, so that the third <code>View</code> gets between custom <code>View</code> and <code>LinearLayout</code>. When I press another button, I would like to make third view GONE again. How can I achieve that?</p>
  
  <p>Here is my XML:</p>
  
  <p></p>
  
  <pre><code>&lt;view
      android:id="@+id/CanvasView"
      android:layout_width="200dp"
      android:layout_height="40dp"
      android:layout_above="@+id/HorizontalScrollView"
      android:layout_centerHorizontal="true"
      android:layout_margin="0dp"
      android:layout_marginBottom="0dp"
      android:layout_marginTop="0dp"
      class="com.example.CanvasView"
      android:orientation="vertical" /&gt;
  
  &lt;HorizontalScrollView
      android:id="@+id/HorizontalScrollView"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_above="@+id/linearLayout2"
      android:clickable="false"
      android:focusable="false"
      android:focusableInTouchMode="false"
      android:visibility="gone" &gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:clickable="false"
          android:focusable="false"
          android:focusableInTouchMode="false"
          android:orientation="horizontal" &gt;
  
      //SOME BUTTONS HERE
      &lt;/LinearLayout&gt;
  
  &lt;/HorizontalScrollView&gt;
  
  &lt;LinearLayout
      android:id="@+id/linearLayout2"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_marginTop="5dp" &gt;
  
      &lt;Button
          android:id="@+id/button1"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_gravity="center_vertical|center_horizontal"
          android:layout_weight="0.4"
          android:maxWidth="200dp"
          android:text="Clear"
          android:textColor="@android:color/white"
          android:textSize="20sp" /&gt;
  
      &lt;Button
          android:id="@+id/settingsButton"
          android:layout_width="44dp"
          android:layout_height="44dp"
          android:layout_gravity="center_vertical|center_horizontal"
          android:background="@drawable/settings_button_selector" /&gt;
  
      &lt;Button
          android:id="@+id/button2"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_gravity="center_vertical|center_horizontal"
          android:layout_weight="0.4"
          android:enabled="false"
          android:maxWidth="200dp"
          android:text="Recognize"
          android:textColor="@android:color/white"
          android:textSize="20sp" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>If I only setVisibility of the third view in OnClick() method, it will appear above LinearLayout and it will overlay the custom View (I tried it before). In other words, it will not move RelativeLayout up. </p>