LinearLayout$LayoutParams 不能转换为 CoordinatorLayout$LayoutParams

LinearLayout$LayoutParams cannot be cast to CoordinatorLayout$LayoutParams

我正在尝试在 2 widget/layout

之间创建一个浮动操作按钮

我 99% 确定我已经使用了这个教程并且有效 How can I add the new "Floating Action Button" between two widgets/layouts

但是现在当我再次尝试这样做时,出现了这个错误

Exception raised during rendering: android.widget.LinearLayout$LayoutParams cannot be cast to android.support.design.widget.CoordinatorLayout$LayoutParams

不知道如何解决?以及如何创建这样的视图

自从使用 android support-design-lib 24.2.0 以来,我遇到了类似的问题,而 24.1.1 一切正常。

更新: Here 是 Android 开源项目 - Issue Tracker

上的相应问题

我设法像这样修复这个错误:

<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:app="http://schemas.android.com/apk/res-auto"
 android:orientation="vertical"
 android:layout_width="match_parent"
 android:layout_height="match_parent">

<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

        <LinearLayout

            android:id="@+id/anchor"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="top"
            android:background="@color/colorPrimary">


                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="40dp"
                    android:text="@string/Homepage"
                    android:textSize="18sp"
                    android:textColor="@color/white"
                    android:id="@+id/place"
                    android:layout_gravity="center_horizontal"
                    android:gravity="top"/>

                <TextView
                    android:id="@+id/fullName"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="15dp"
                    android:layout_marginBottom="15dp"
                    android:textColor="@color/white"
                    android:textSize="25sp"
                    android:layout_gravity="center_horizontal" />

        </LinearLayout>
        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="16dp"
            android:clickable="true"
            android:src="@drawable/ic_admin"
            app:fabSize="mini"
            app:layout_anchor="@id/anchor"
            app:layout_anchorGravity="bottom|right|end"/>

    </android.support.design.widget.CoordinatorLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="20dp"
            android:orientation="vertical">

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/List"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:scrollbars="vertical"
                        android:layout_weight="1"/>

                    <Button
                        android:id="@+id/btnlogout"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="@string/btn_logout"
                        android:background="@color/red"/>
        </LinearLayout>

我的 LinearLayout 包装了 coordinatorLayout 而不是 Coordinator 作为根视图。