我刚刚将 appcompat 库从 23.1.1 更新到 23.2,现在应用程序停止处理 java.lang.IllegalStateException:视图无法锚定到父 CoordinatorLayout。
java.lang.IllegalStateException: View can not be anchored to the the parent CoordinatorLayout
崩溃来自于resolveAnchorView
的方法CoordinatorLayout
当父级时(CoordinatorLayout 未处于编辑模式)。布局用作基本活动中的根元素,并包含不同的布局(工具栏、进度栏,最后是具有活动膨胀布局的相对布局。
<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",
这是错误的,您需要设置协调器的一些直接子级作为此布局锚点
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)