Hugo Houyez
Hugo Houyez

Reputation: 490

LinearLayout$LayoutParams cannot be cast to CoordinatorLayout$LayoutParams

Im trying to create a Floating Action button between 2 widget/layout

im 99% sure i already use this tutorial and that worked How can I add the new "Floating Action Button" between two widgets/layouts

But now when i try to do this again i have this error

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

Dont know how to fix it ? And how to create a view like this one enter image description here

Upvotes: 1

Views: 4460

Answers (2)

Thomas S.E.
Thomas S.E.

Reputation: 1588

I have a similar problem since using android support-design-lib 24.2.0, with 24.1.1 everything works fine.

Update: Here is the corresponding issue on the Android Open Source Project - Issue Tracker

Upvotes: 4

Hugo Houyez
Hugo Houyez

Reputation: 490

i manage to fix this error like this :

<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>

My LinearLayout is wrapping the coordinatorLayout instead of the Coordinator being the rootview.

Upvotes: 0

Related Questions