title: Aligning TextView center horizontaly and bottom to the parent
body: <p>In this layout I have two Views - the ImageButton at bottom right and the TextView at center bottom. When <code>android:visibility</code> of both of views is set to <code>visible</code> - all is aligned as needed. But if I set <code>android:visibility</code> for ImageButton to <code>gone</code> - EditText goes to the left edge of layout.</p>
  
  <p>Questions:</p>
  
  <p>1) Why it is happening so?;</p>
  
  <p>2) How to achieve not changing place of <code>EditText</code> on setting <code>ImageButton</code> visibility to <code>gone</code>? I need to get the same layout as on the left picture (see below), but without ImageButton. (I know, one possibility would be setting <code>visibility</code> not to <code>gone</code>, but to <code>invisible</code>, but I'm more interested in the solution with <code>visibility = "gone"</code>)</p>
  
  <p>P.s.: The first two layouts - <code>RelativeLayout</code> and <code>FrameLayout</code> are mandatory - they are used for other stuff, I just removed all that is not related to question.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent" &gt;
  
      &lt;FrameLayout
          android:id="@+id/mForSearchFragment"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_above="@id/mForAdMediation"
          android:layout_alignWithParentIfMissing="true" &gt;
  
          &lt;RelativeLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="horizontal" &gt;
  
              &lt;EditText
                  android:id="@+id/mSearchEditText"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_alignParentBottom="true"
                  android:layout_centerHorizontal="true"
                  android:ems="5"
                  android:imeOptions="actionSearch"
                  android:inputType="text"
                  android:visibility="visible" &gt;
  
                  &lt;requestFocus /&gt;
              &lt;/EditText&gt;
  
              &lt;ImageButton
                  android:id="@+id/mSearchButton"
                  android:layout_width="48dp"
                  android:layout_height="48dp"
                  android:layout_alignParentBottom="true"
                  android:layout_alignParentRight="true"
                  android:background="@drawable/dark_button"
                  android:src="@drawable/tab_search"
                  android:visibility="visible" /&gt;
          &lt;/RelativeLayout&gt;
      &lt;/FrameLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Here are layouts:
  <img src="https://i.stack.imgur.com/DbUfv.png" alt="layouts"></p>