title: Anchor FloatingActionButton
body: <p>I'm using Android Support <code>FloatingActionButton</code> (FAB) and <code>CoordinatorLayout</code> and I want anchor FAB to a <code>CardView</code>.</p>
  
  <p>This is my code:</p>
  
  <pre><code>&lt;android.support.design.widget.CoordinatorLayout
  ... /&gt;
  
  &lt;LinearLayout
    ...&gt;
       &lt;android.support.v7.widget.CardView
          android:id="@+id/container"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" /&gt;
      ...
  &lt;/LinearLayout&gt;
  
  &lt;android.support.design.widget.FloatingActionButton
      android:id="@+id/fab"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_margin="32dp"
      android:src="@android:drawable/ic_menu_send"
      app:layout_anchor="@id/container"
      app:layout_anchorGravity="bottom|end" /&gt;
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p>This works but sometimes FAB appear on left-top side of page, not anchored. </p>
  
  <p>In this case, when I press FAB, it comes back anchored. <code>CardView</code> isn't a direct child of <code>CoordinatorLayout</code> but [Support Library 24.2.1] that i'm using allows this.</p>
  
  <p>What could be the problem?</p>