0

Hello friends please help me whats problem here its work fine on sdk 23 now I upgrade my sdk from 23 to 28 its giving this error. Its mostly error in anchor tag I don't know how fix this error please any expert is here who can help me

An anchor may not be changed after CoordinatorLayout measurement begins before layout is complete? here is my code

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

    <!--<include layout="@layout/base_toolbar"/>-->
    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/myCoordinatorLayout"
        android:layout_width="match_parent"
        android:gravity="center"
        android:layout_height="match_parent"
        >

        <LinearLayout
            android:id="@+id/toDoEmptyView"
            android:orientation="vertical"
            android:gravity="center"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:src="@drawable/empty_view_bg"
                android:layout_width="100dp"
                android:layout_height="100dp"/>

            <TextView
                android:text="@string/no_to_dos"
                android:textColor="@color/secondary_text"
                android:textSize="16sp"
                android:paddingTop="4dp"
                android:paddingBottom="8dp"
                android:gravity="center"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

        </LinearLayout>


        <!--<include layout="@layout/base_toolbar"/>-->


        <!--</android.support.design.widget.AppBarLayout>-->


        <com.rock.notepad.minimaltodo.Utility.RecyclerViewEmptySupport
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:id="@+id/toDoRecyclerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>


        <android.support.design.widget.FloatingActionButton
            android:src="@drawable/ic_add_white_24dp"
            android:id="@+id/addToDoItemFAB"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="16dp"
            app:layout_anchor="@id/myCoordinatorLayout"
            app:layout_anchorGravity="bottom|right|end"

            />


    </android.support.design.widget.CoordinatorLayout>
</LinearLayout>
ramya br
  • 225
  • 2
  • 17
aneel ilyas
  • 31
  • 10

1 Answers1

0

In FloatingActionButton tag don't use layout_anchor to CoordinatorLayout. Use the below child of CoordinatorLayout.

Please check this.It is working for me

<android.support.design.widget.FloatingActionButton
            android:src="@drawable/ic_add_white_24dp"
            android:id="@+id/addToDoItemFAB"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="16dp"
            app:layout_anchor="@id/toDoEmptyView"
            app:layout_anchorGravity="bottom|right|end"

            />
ramya br
  • 225
  • 2
  • 17