View can not be anchored to the the parent CoordinatorLayout
This started to happened in support design library v.23.2.0
compile 'com.android.support:design:23.2.0'
I know this started with v23.2.0 because my app was working fine before (v.23.1.2) and started to present same failure after update.
Error is simple:
One of your views is anchored to its parent Coordinator Layout. However, starting at v.23.2.0, this is no longer allowed.
I think the error is in your FAB:
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_add"
...
app:layout_anchor="@+id/container"
... />
I believe that id/container
is a parent CoordinatorLayout
Fixing
Right way is change the layout_anchor
and use another view as anchor (parent Layout or any other view which is fixed to bottom of the screen).
The view to which the FAB is anchored must be a descendant view of the CoordinatorLayout.
And if the view is a layout, the FAB must not be inside the layout, otherwise the anchor gravity settings won't work. For example:
<android.support.design.widget.CoordinatorLayout
android:id="@+id/content_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
.
.
.
<FrameLayout
android:id="@+id/attachment_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/fab_margin_end"
android:layout_marginTop="@dimen/fab_margin_top"
android:scaleType="center"
android:src="@drawable/ic_action_save"
app:borderWidth="0dp"
app:elevation="@dimen/fab_elevation"
app:layout_anchor="@id/attachment_layout"
app:layout_anchorGravity="top|end"
app:rippleColor="@color/accent_highlight" />
</android.support.design.widget.CoordinatorLayout>