BottomSheetBehavior is not a child of CoordinatorLayout

在用BottomSheet的時候一直報這個錯誤

檢查了很久,最後才發現我是直接在原始的xml寫佈局,原始佈局是

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayoutxmlns

    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <Button
        android:layout_width="wrap_content"
android:layout_gravity="center"
        android:layout_height="wrap_content"
        android:onClick="dd" />
<android.support.v4.widget.NestedScrollView
    android:layout_gravity="center_horizontal"
    android:id="@+id/ll"
    app:layout_behavior="@string/bottom_sheet_behavior"
    app:behavior_hideable="true"
    app:behavior_peekHeight="50dp"
    android:layout_width="300dp"
    android:layout_height="wrap_content">

    <LinearLayout
        app:layout_behavior="@string/bottom_sheet_behavior"
android:background="#817e7e"
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:layout_height="match_parent">


        <Button
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:text="Button" />


        <Button

            android:id="@+id/button"
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:text="Button" />

        <SeekBar
            android:id="@+id/seekBar"
            android:layout_width="match_parent"
            android:layout_height="56dp" />

    </LinearLayout>


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

注意第一行是android.support.constraint.ConstraintLayoutxmlns!!!!是約束佈局

把餘數佈局改成CoordinatorLayout就可以了。。。。。簡直坑爹!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章