title: Layout constraint between Views not preserved when included as Fragment
body: <p>I have a fragment_cameracontroller.xml which defines how buttons are laid out:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                tools:context="cc.closeup.android.activities.TileActivity$CameraController"
                android:id="@+id/cameracontroller_layout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="right|top"&gt;
  
      &lt;LinearLayout
          android:orientation="horizontal"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginRight="150dp"
          android:layout_marginTop="5dp"
          android:id="@+id/cameracontroller_layout_top"
          android:layout_toLeftOf="@+id/cameracontroller_layout_right"&gt;
  
          &lt;ImageButton
              android:id="@+id/button_togglecamera"
              android:background="@android:drawable/ic_menu_camera"
              android:layout_marginRight="8dp"
              android:layout_width="48dp"
              android:layout_height="48dp"/&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:orientation="vertical"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/cameracontroller_layout_right"
          android:layout_marginTop="15dp"
          android:layout_marginRight="5dp"&gt;
  
          &lt;Button
              android:layout_width="72dp"
              android:layout_height="72dp"
              android:id="@+id/button_talk"
              android:background="@drawable/button_talk"
              android:text="@string/talk"
              android:textColor="@color/white"/&gt;
  
      &lt;/LinearLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Specifically, pay attention to the <code>android:layout_toLeftOf="@+id/cameracontroller_layout_right"</code> constraint, which specifies how the buttons relate to each other.</p>
  
  <p>In the Preview in Android Studio, the relationship (green arrow) is honored:</p>
  
  <p><img src="https://i.stack.imgur.com/PGnQg.png" alt="View Relationship"></p>
  
  <p>but when I later embed that fragment xml in an Activity, both buttons are on top of each other (on the device). Here's the Activity XML:</p>
  
  <pre><code>&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"
          android:orientation="vertical"&gt;
  
      &lt;fragment
          android:name="cc.closeup.android.activities.TileActivity$CameraControllerFragment"
          android:id="@+id/cameracontroller"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          tools:layout="@layout/fragment_cameracontroller"
          android:layout_alignParentTop="true"
          android:layout_alignParentRight="true"/&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>I inflate the fragment with the following static code snippet:</p>
  
  <pre><code>public static class CameraControllerFragment extends Fragment {
      @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          return inflater.inflate(R.layout.fragment_cameracontroller, container, false);
      }
  }
  </code></pre>
  
  <p>Is there anything that I do wrong? I know I may lose width and height of the fragment's root layout in such a case, dependent on how I inflate, but that relationship is between two child views.</p>