问题描述
你好朋友,请帮我看看这里有什么问题,它在 sdk 23 上工作正常,现在我将我的 sdk 从 23 升级到 28,它给出了这个错误.它主要是锚标记中的错误我不知道如何解决这个错误,请任何专家在这里可以帮助我
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
CoordinatorLayout 测量开始后,在布局完成之前,锚点可能不会改变?这是我的代码
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>
推荐答案
在 FloatingActionButton 标签中不要使用 layout_anchor 到 CoordinatorLayout.使用 CoordinatorLayout 的以下子项.
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"
/>
这篇关于在布局完成之前,CoordinatorLayout 测量开始后可能不会更改锚点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!