title: Passing LiveData as <layout> tag argument
body: <p>I have quick question about my code. I'm writing an app using Android MVVM with LiveData. I want to create loading layout which is will be included in many views. Main goal is to have ability of passing live data representing if layout should be visible and what text info should be displayed with progress bar.</p>
  
  <p>So far I created loading indicator layout, and definded two variables "indicatorVisibility" and "progressText". In attached code one of values is commented out. I created also BindingAdapters to set visibility and text on controls.</p>
  
  <p>This is my layout with progress bar</p>
  
  <p></p>
  
  <pre><code>&lt;data&gt;
  
      &lt;variable
          name="indicatorVisibility"
          type="android.arch.lifecycle.LiveData"/&gt;
      &lt;!--&lt;variable--&gt;
          &lt;!--name="progressText"--&gt;
          &lt;!--type="android.arch.lifecycle.LiveData"/&gt;--&gt;
  &lt;/data&gt;
  
  
  &lt;android.support.constraint.ConstraintLayout
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@color/layout_loading_background"
      &gt;
  
      &lt;ProgressBar
          android:id="@+id/progressBar2"
          style="?android:attr/progressBarStyle"
          android:layout_width="@dimen/layout_loading_progress_bar_size"
          android:layout_height="@dimen/layout_loading_progress_bar_size"
          android:layout_marginTop="8dp"
          android:layout_marginBottom="8dp"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toStartOf="@+id/textView7"
          app:layout_constraintHorizontal_bias="0.5"
          app:layout_constraintHorizontal_chainStyle="packed"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent" /&gt;
  
      &lt;!--android:text="@{progressText}"--&gt;
  
      &lt;TextView
          android:id="@+id/textView7"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          tools:text="TextView"
          android:textColor="@color/layout_loading_text"
          android:textSize="@dimen/layout_loading_text_size"
          app:layout_constraintBottom_toBottomOf="@+id/progressBar2"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintHorizontal_bias="0.5"
          app:layout_constraintStart_toEndOf="@+id/progressBar2"
          app:layout_constraintTop_toTopOf="@+id/progressBar2" /&gt;
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>This is how i include it in fragment layout</p>
  
  <pre><code>&lt;include layout="@layout/layout_loading_info"
              app:indicatorVisibility="@{viewModel.isBusy}"
              /&gt;
  </code></pre>
  
  <p>And those are my bind adapters:</p>
  
  <pre><code>@BindingAdapter("android:visibility")
  fun getVisibility(view: View, liveData: LiveData&lt;Boolean&gt;){
          liveData.observe(view.getLifecycleOwner(), Observer {
          view.visibility = if(it == true) View.VISIBLE else View.INVISIBLE
      })
  }
  
  @BindingAdapter("app:text")
  fun getText(view: TextView, liveData : LiveData&lt;Int&gt;)
  {
      liveData.observe(view.getLifecycleOwner(), Observer {
           it?.let{
              view.text = view.context.resources.getString(it)
          }
      })
  }
  </code></pre>
  
  <p>So far I tried passing simple types like Integer and it works. The problem lays in LiveData. Even when I don't use variables inside included layout I get error (error message tells nothing). </p>
  
  <p>I saw similar stack task [here] : <a href="https://stackoverflow.com/questions/50722783/applying-databinding-adapter-to-include-tag">Applying databinding adapter to include tag</a> but they passed the whole viewModel, which is not a flexible enough solution for me.</p>