视图无法锚定到父CoordinatorLayout [英] View can not be anchored to the parent CoordinatorLayout
问题描述
我刚刚从23.1.1升级到了Appcompat库,直到23.2,现在应用程序停止在java.lang.IllegalStateException上工作.视图无法锚定到父CoordinatorLayout.
I just updated to appcompat library from 23.1.1 to 23.2 and now application stopped working on java.lang.IllegalStateException: View can not be anchored to the the parent CoordinatorLayout.
java.lang.IllegalStateException: View can not be anchored to the the parent CoordinatorLayout
当父级(CoordinatorLayout不在编辑模式下)时,崩溃来自CoordinatorLayout
的resolveAnchorView
方法.布局被用作基础活动的根元素,并且包含不同的布局(工具栏,进度栏以及最终具有相对活动布局的相对布局).
Crash comes from resolveAnchorView
method of CoordinatorLayout
when parent (CoordinatorLayout is not in edit mode). Layout is used as root element in base activity and contains different layouts (toolbar, progressbar and finally relativelayout with inflated layout of activity.
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/base_activity__main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/shared__color_primary">
<ProgressBar
android:id="@+id/base_activity__progress_bar_top"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"
android:visibility="gone" />
<ViewSwitcher
android:id="@+id/base_activity__switcher"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/base_activity__progress_bar_top">
<LinearLayout
android:id="@+id/base_activity__progress_bar_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/_loading"
android:textStyle="italic" />
<ProgressBar
android:id="@+id/base_activity__progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:indeterminate="true" />
</LinearLayout>
<RelativeLayout
android:id="@+id/base_activity__main_content_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</ViewSwitcher>
<RelativeLayout
android:id="@+id/base_activity__add_button__container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent" />
</android.support.design.widget.CoordinatorLayout>
推荐答案
您无法将布局锚点属性设置为协调器布局本身app:layout_anchor="@id/base_activity__main_layout",
,这是错误的,您需要为此设置协调器的直接子级布局锚点
You cannot set the layout anchor attribute to the co ordinator layout itself app:layout_anchor="@id/base_activity__main_layout",
this is wrong, you need to set some direct child of the co ordinator as this layouts anchor
这篇关于视图无法锚定到父CoordinatorLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!