I am using Android support FloatingActionButton(FAB) and CoordinatorLayout, and I want to bind FAB to CardView.
This is my code:
<android.support.design.widget.CoordinatorLayout
... />
<LinearLayout
...>
<android.support.v7.widget.CardView
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
...
</LinearLayout>
<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" />
</android.support.design.widget.CoordinatorLayout>
This works, but sometimes FAB appears on the left side of the page, rather than at anchor.
In this case, when I press FAB, it returns to the anchor. CardViewis not a direct child CoordinatorLayout, but the [Support Library 24.2.1] that I use allows this.
What could be the problem?
source
share