title: Will the second layout UI overwrite the first layout UI in android Studio?
body: <p>The following sample code is from <a href="https://github.com/android/camera/tree/master/CameraXBasic" rel="nofollow noreferrer">https://github.com/android/camera/tree/master/CameraXBasic</a>.</p>
  
  <p>In CameraFragment.kt, the system load fragment_camera.xml layout UI first, then load camera_ui_container.xml layout UI.</p>
  
  <p>Will the second layout UI overwrite the first layout UI in android Studio? In my mind, the fragment_camera.xml will be hidden, right?</p>
  
  <p><strong><a href="https://github.com/android/camera/blob/master/CameraXBasic/app/src/main/java/com/android/example/cameraxbasic/fragments/CameraFragment.kt" rel="nofollow noreferrer">CameraFragment.kt</a></strong></p>
  
  <pre><code>override fun onCreateView(
          inflater: LayoutInflater,
          container: ViewGroup?,
          savedInstanceState: Bundle?): View? =
          inflater.inflate(R.layout.fragment_camera, container, false)
  
  
  
  override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        ...
        updateCameraUi()
   }
  
  
  private fun updateCameraUi() {
  
      // Remove previous UI if any
      container.findViewById&lt;ConstraintLayout&gt;(R.id.camera_ui_container)?.let {
          container.removeView(it)
      }
  
      // Inflate a new view containing all UI for controlling the camera
      val controls = View.inflate(requireContext(), R.layout.camera_ui_container, container)
    ...
  </code></pre>
  
  <p>}</p>
  
  <p><strong>fragment_camera.xml</strong></p>
  
  <pre><code>&lt;androidx.constraintlayout.widget.ConstraintLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/camera_container"
      android:background="@android:color/black"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;TextureView
          android:id="@+id/view_finder"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  
  <p><strong>camera_ui_container.xml</strong></p>
  
  <pre><code>&lt;androidx.constraintlayout.widget.ConstraintLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/camera_ui_container"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;!-- Camera control and gallery buttons --&gt;
      &lt;ImageButton
          android:id="@id/camera_switch_button"
          android:layout_width="@dimen/round_button_medium"
          android:layout_height="@dimen/round_button_medium"
          android:layout_marginRight="@dimen/margin_xlarge"
          android:layout_marginBottom="@dimen/margin_small"
          android:padding="@dimen/spacing_small"
          android:scaleType="fitXY"
          android:background="@android:color/transparent"
          app:srcCompat="@drawable/ic_switch"
          app:layout_constraintRight_toRightOf="parent"
          app:layout_constraintBottom_toBottomOf="parent"
          android:contentDescription="@string/gallery_button_alt" /&gt;
  
      &lt;ImageButton
          android:id="@id/camera_capture_button"
          android:layout_width="@dimen/round_button_large"
          android:layout_height="@dimen/round_button_large"
          android:layout_marginRight="@dimen/shutter_button_margin"
          android:background="@drawable/ic_shutter"
          android:contentDescription="@string/capture_button_alt"
          android:scaleType="fitXY"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintTop_toTopOf="parent" /&gt;
  
      &lt;ImageButton
          android:id="@id/photo_view_button"
          android:layout_width="@dimen/round_button_medium"
          android:layout_height="@dimen/round_button_medium"
          android:layout_marginRight="@dimen/margin_xlarge"
          android:layout_marginTop="@dimen/margin_small"
          android:padding="@dimen/spacing_large"
          android:scaleType="fitXY"
          android:background="@drawable/ic_outer_circle"
          app:srcCompat="@drawable/ic_photo"
          app:layout_constraintRight_toRightOf="parent"
          app:layout_constraintTop_toTopOf="parent"
          android:contentDescription="@string/switch_camera_button_alt" /&gt;
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>