0

我收到 java.lang.RuntimeException: Unable to start activity java.lang.IllegalArgumentException: View is not a child of CoordinatorLayout.working with bottom sheet,我尝试了很多组合,但我仍然没有得到解决方案。请告诉我任何解决方案。提前谢谢你。

            <?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);
4

1 回答 1

3

它告诉您只能将 aBottomSheetBehavior放入 CoordinatorLayout。

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

于 2019-05-21T06:38:06.347 回答