title: How to set NavigationView's headerView with Anko DSL?
body: <p>In general XML layout, the default main layout is like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v4.widget.DrawerLayout 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"
      android:id="@+id/drawer_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fitsSystemWindows="true"
      tools:openDrawer="start"&gt;
  
      &lt;include
          layout="@layout/app_bar_main"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  
      &lt;android.support.design.widget.NavigationView
          android:id="@+id/nav_view"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:layout_gravity="start"
          android:fitsSystemWindows="true"
          app:headerLayout="@layout/nav_header_main"
          app:menu="@menu/activity_main_drawer" /&gt;
  
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>I tried to code this with Anko DSL:</p>
  
  <pre><code>...
  
  override fun createView(ui: AnkoContext&lt;MainActivity&gt;) = with(ui) {
      drawerLayout {
          lparams(width = matchParent, height = matchParent)
          id = ID_DRAWER_LAYOUT
          fitsSystemWindows = true
  
          navigationView {
              lparams(width = wrapContent, height = matchParent)
              id = ID_NAVIGATION_VIEW
              foregroundGravity = Gravity.START
              fitsSystemWindows = true
  
              addHeaderView(navHeaderView()) //// PROBLEM HERE ////
              inflateMenu(R.menu.activity_main_drawer)
          }
      }
  }
  
  private fun ViewGroup.navHeaderView() {
      linearLayout {
          lparams(width = matchParent, height = dip(160))
          backgroundResource = R.drawable.side_nav_bar
          gravity = Gravity.BOTTOM
          orientation = LinearLayout.VERTICAL
          setPadding(dip(64), dip(16), dip(64), dip(16))
  
          imageView {
              id = ID_IMAGE_VIEW
              topPadding = dip(16)
              imageResource = android.R.drawable.sym_def_app_icon
          }
  
          textView {
              lparams(width = matchParent, height = wrapContent)
              id = ID_TEXT_NAME
              topPadding = dip(16)
              text = "test1"
              if (Build.VERSION.SDK_INT &gt;= 23) {
                  setTextAppearance(R.style.TextAppearance_AppCompat_Body1)
              } else {
                  setTextAppearance(context, android.R.style.TextAppearance_Medium)
              }
          }
  
          textView {
              id = ID_TEXT_DESCRIPTION
              text = "test2"
          }
      }
  }
  
  ...
  </code></pre>
  
  <p>The marked line throws an exception saying that the view has already had a parent.</p>
  
  <hr>
  
  <p>Then I tried to use the Anko DSL Preview plugin to convert the xml automatically, it just did it like this, not completely changed it into Anko DSL:</p>
  
  <pre><code>android.support.v4.widget.DrawerLayout {
      id = Ids.drawer_layout
  
      include&lt;View&gt;(R.layout.app_bar_main).lparams(width = matchParent, height = matchParent)
      org.mewx.projectprpr.template.NavigationFitSystemView {
          id = Ids.nav_view
          app:headerLayout = @layout/nav_header_main //// HERE ////
          app:menu = @menu/activity_main_drawer
      }.lparams(width = wrapContent, height = matchParent)
  }
  </code></pre>
  
  <p>How can I add the header view with Anko DSL?</p>
  
  <p>Thanks!</p>