title: Android include layout dynamically with data-binding library
body: <p>I'm using MVVM framework for Android application with data-binding library.</p>
  
  <p>I have some reusable compoments, that should have every activity. f.e. toolbar, menu, floating action button.</p>
  
  <p>I want to create a generic activity, that will implement all these reusable features and then every activity class will be inherited from this generic activity. I also have GenericViewModel class and every other ViewModel is inherited from this generic class.</p>
  
  <p>But I have a problem with layout. I want to create generic layout file and include there sublayout dinamically. f.e.</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;layout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"&gt;
  
      &lt;data&gt;
  
          &lt;variable
              name="data"
              type="com.mypackage.genericViewModel" /&gt;
      &lt;/data&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical"&gt;
  
          &lt;include
              bind:data="@{data}"
              layout="@layout/toolbar"
              android:layout_width="match_parent"
              android:layout_height="wrap_content" /&gt;
  
          &lt;include
              layout="@{Here i want to have dynamic variable}"
              android:layout_width="match_parent"
              android:layout_height="wrap_content" /&gt;
      &lt;/LinearLayout&gt;&lt;/layout&gt;
  </code></pre>
  
  <p>I do not want to copy / paste this code for each activity, but data-binding library does not allow to include layout dynamically. Is there any solution for such cases?</p>