title: Android <include> layout change after navigateUp()
body: <p>I have an activity that has two fragments. I have created a layout that is reusable as following:</p>
  <p>Here is the xml of custom layout</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout 
  xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
  xmlns:tools=&quot;http://schemas.android.com/tools&quot;
  android:layout_width=&quot;match_parent&quot;
  android:layout_height=&quot;wrap_content&quot;&gt;
  
  &lt;androidx.appcompat.widget.AppCompatTextView
      android:id=&quot;@+id/tvFormTitle&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:textColor=&quot;@color/black1&quot;
      android:textSize=&quot;@dimen/ssp_10&quot;
      android:visibility=&quot;visible&quot;
      app:layout_constraintStart_toStartOf=&quot;parent&quot;
      app:layout_constraintTop_toTopOf=&quot;parent&quot;
      tools:text=&quot;Email&quot; /&gt;
  
  &lt;androidx.constraintlayout.widget.ConstraintLayout
      android:id=&quot;@+id/clForm&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:layout_marginTop=&quot;@dimen/sdp_4&quot;
      android:background=&quot;@drawable/sh_all_round_form&quot;
      android:paddingStart=&quot;@dimen/sdp_12&quot;
      android:paddingEnd=&quot;@dimen/sdp_12&quot;
      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
      app:layout_constraintStart_toStartOf=&quot;parent&quot;
      app:layout_constraintTop_toBottomOf=&quot;@+id/tvFormTitle&quot;&gt;
  
      &lt;androidx.appcompat.widget.AppCompatEditText
          android:id=&quot;@+id/etForm&quot;
          style=&quot;@style/et_form&quot;
          android:layout_width=&quot;0dp&quot;
          android:layout_weight=&quot;1&quot;
          app:layout_constraintEnd_toStartOf=&quot;@+id/ivSwitchPassword&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
      &lt;androidx.appcompat.widget.AppCompatImageView
          android:id=&quot;@+id/ivSwitchPassword&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_alignParentRight=&quot;true&quot;
          android:paddingStart=&quot;@dimen/sdp_8&quot;
          android:paddingTop=&quot;@dimen/sdp_8&quot;
          android:paddingEnd=&quot;@dimen/sdp_2&quot;
          android:paddingBottom=&quot;@dimen/sdp_8&quot;
          android:src=&quot;@drawable/ic_eye&quot;
          android:visibility=&quot;gone&quot;
          app:layout_constraintBottom_toBottomOf=&quot;@+id/etForm&quot;
          app:layout_constraintEnd_toStartOf=&quot;@+id/ivCancel&quot;
          app:layout_constraintTop_toTopOf=&quot;@+id/etForm&quot; /&gt;
  
      &lt;androidx.appcompat.widget.AppCompatImageView
          android:id=&quot;@+id/ivCancel&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_alignParentRight=&quot;true&quot;
          android:paddingStart=&quot;@dimen/sdp_12&quot;
          android:paddingTop=&quot;@dimen/sdp_12&quot;
          android:paddingBottom=&quot;@dimen/sdp_12&quot;
          android:src=&quot;@drawable/white_close&quot;
          android:visibility=&quot;gone&quot;
          app:layout_constraintBottom_toBottomOf=&quot;@+id/etForm&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;@+id/etForm&quot;
          app:tint=&quot;@color/grey_shade5&quot; /&gt;
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  
  &lt;androidx.appcompat.widget.AppCompatTextView
      android:id=&quot;@+id/tvMessage&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:layout_marginTop=&quot;@dimen/sdp_5&quot;
      android:textColor=&quot;@color/colorError&quot;
      android:textSize=&quot;@dimen/ssp_10&quot;
      android:visibility=&quot;visible&quot;
      app:layout_constraintStart_toStartOf=&quot;parent&quot;
      app:layout_constraintTop_toBottomOf=&quot;@+id/clForm&quot;
      tools:text=&quot;This field is required&quot; /&gt;
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  <p>I am using this custom la in Fragment A as follow:</p>
  <pre><code>                &lt;include
                      android:id=&quot;@+id/email&quot;
                      layout=&quot;@layout/layout_form_edittext&quot;
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:layout_marginTop=&quot;@dimen/sdp_36&quot;
                      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
                      app:layout_constraintStart_toStartOf=&quot;parent&quot;
                      app:layout_constraintTop_toBottomOf=&quot;@+id/tvDescription&quot; /&gt;
  
                  &lt;include
                      android:id=&quot;@+id/password&quot;
                      layout=&quot;@layout/layout_form_edittext&quot;
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:layout_marginTop=&quot;@dimen/sdp_12&quot;
                      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
                      app:layout_constraintStart_toStartOf=&quot;parent&quot;
                      app:layout_constraintTop_toBottomOf=&quot;@+id/email&quot; /&gt;
  </code></pre>
  <p>I am using Fragment navigation to move from Fragment A to B. Entering values in email and password and move to Fragment B and get back to Fragment A by pressing back or navigateUp().  Email field contains the value of password field.</p>
  <p>Edit:</p>
  <p>Same layout it used in Custom Compound class as following getting same issue.</p>
  <pre><code>class FormView @JvmOverloads
  constructor(
  private val ctx: Context,
  private val attributeSet: AttributeSet? = null,
  private val defStyleAttr: Int = 0
  ) : ConstraintLayout(ctx, attributeSet, defStyleAttr) {
  
  private var formTitle = &quot;&quot;
  private var passwordType = false
  private var showMessage = false
  
  init {
      val inflater = ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
      val attributes = ctx.obtainStyledAttributes(attributeSet, R.styleable.FormView)
      attributes.getString(R.styleable.FormView_formTitle)?.let { formTitle = it }
      passwordType = attributes.getBoolean(R.styleable.FormView_passwordType, passwordType)
      showMessage = attributes.getBoolean(R.styleable.FormView_showErrorMessage, false)
      attributes.recycle()
  
      inflater.inflate(R.layout.layout_form_edittext, this)
  
      setTitle(formTitle)
      setPasswordType(passwordType)
      errorMessageVisibility(showMessage)
      borderVisibility(false)
  
  
      ivSwitchPassword.setOnClickListener {
          updatePasswordVisibility()
      }
  
      ivCancel.setOnClickListener {
          etForm.text?.clear()
          clearError()
      }
  }
  
  fun showError(msg: String) {
      msg?.let {
          tvMessage.text = it
          cancelBtnVisibility(true)
          errorMessageVisibility(true)
          borderVisibility(true)
      }
  }
  
  fun clearError() {
      tvMessage.text = &quot;&quot;
      cancelBtnVisibility(false)
      errorMessageVisibility(false)
      borderVisibility(false)
  }
  
  private fun errorMessageVisibility(flag: Boolean) {
      if (flag) tvMessage.visible() else tvMessage.gone()
  }
  
  private fun cancelBtnVisibility(flag: Boolean) {
      if (flag) ivCancel.visible() else ivCancel.gone()
  }
  
  private fun borderVisibility(flag: Boolean) {
      val drawable = clForm.background as GradientDrawable
      if(flag) drawable.setStroke(1, Color.parseColor(&quot;#c32329&quot;))
      else drawable.setStroke(0, Color.TRANSPARENT)
  }
  
  fun setPasswordType(passwordType: Boolean) {
      if(!passwordType) ivSwitchPassword.gone()
      else {
          ivSwitchPassword.visible()
          etForm.inputType = InputTypeUtils.getInputTypeByProperty(&quot;textPassword&quot;)
      }
  }
  
  fun setTitle(title: String) {
      tvFormTitle.text = title
  }
  
  private fun updatePasswordVisibility() {
      if (etForm.transformationMethod is PasswordTransformationMethod) {
          etForm.transformationMethod = null
      } else {
          etForm.transformationMethod = PasswordTransformationMethod()
      }
      etForm.setSelection(etForm.length())
  }
  }
  </code></pre>