该视图不是CoordinatorLayout的子级

时间:2019-05-21 06:01:38

标签: android android-layout view nestedrecyclerview

我正在获取java.lang.RuntimeException:无法启动活动java.lang.IllegalArgumentException:该视图不是CoordinatorLayout.child的底部工作表,我尝试了很多组合,但仍未得到解决方案。请告诉我任何解决方案。谢谢。

            <?xml version="1.0" encoding="utf-8"?>
            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                xmlns:tools="http://schemas.android.com/tools"
                android:id="@+id/beyprod"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">


                <LinearLayout
                    android:id="@+id/toolbarLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true"
                    android:orientation="vertical">

                    <include
                        android:id="@+id/toolbar"
                        layout="@layout/toolbar" />

                </LinearLayout>

                <!-- <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">
                    <FrameLayout
                        android:id="@+id/bottom_sheet"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        app:layout_behavior="@string/bottom_sheet_behavior" />
                </LinearLayout>-->

                <android.support.v4.widget.NestedScrollView

                    android:id="@+id/bottom_sheet"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:fillViewport="true"
                    app:layout_behavior="@string/bottom_sheet_behavior">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical">


                        <RelativeLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            tools:context=".retailerModule.cart.activity.AddressListActivity">

                            <ProgressBar
                                android:id="@+id/progress_bar"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_below="@+id/relaLaySearch"
                                android:layout_gravity="center|top"
                                android:visibility="gone" />

                            <LinearLayout
                                android:layout_width="match_parent"
                                android:layout_height="match_parent"
                                android:layout_above="@+id/confirmBtn"
                                android:orientation="vertical">


                                <LinearLayout
                                    android:layout_width="match_parent"
                                    android:layout_height="wrap_content">

                                    <android.support.v7.widget.RecyclerView
                                        android:id="@+id/recycler"
                                        android:layout_width="match_parent"
                                        android:layout_height="wrap_content">

                                    </android.support.v7.widget.RecyclerView>

                                </LinearLayout>


                                <TextView
                                    android:id="@+id/addNewAddress"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_alignParentBottom="true"
                                    android:layout_gravity="right"
                                    android:layout_marginTop="15dp"
                                    android:layout_marginRight="10dp"
                                    android:layout_marginBottom="40dp"
                                    android:background="@color/green"
                                    android:gravity="center"
                                    android:padding="10dp"
                                    android:text="New Address"
                                    android:textColor="@color/colorWhite" />
                            </LinearLayout>

                            <android.support.v7.widget.AppCompatButton
                                android:id="@+id/continueBtn"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_alignParentBottom="true"
                                android:layout_gravity="right"
                                android:background="@color/color_blue"
                                android:gravity="center"
                                android:text="SAVE"
                                android:textColor="@color/colorWhite"
                                android:visibility="gone" />
                        </RelativeLayout>
                    </LinearLayout>

                </android.support.v4.widget.NestedScrollView>


            </LinearLayout>

当我尝试运行此行时出现异常

  NestedScrollView  mBehavior = BottomSheetBehavior.from(bottom_sheet);

1 个答案:

答案 0 :(得分:0)

它告诉您只能将BottomSheetBehaviour放入CoordinatorLayout中。

因此,将CoordinatorLayout用作根布局,并将其直接放置在此处(不在某些嵌套视图中)