Android 点击按钮时,底板不显示

Android 点击按钮时,底板不显示,android,android-studio,android-layout,android-coordinatorlayout,bottom-sheet,Android,Android Studio,Android Layout,Android Coordinatorlayout,Bottom Sheet,我目前正在使用coordinatorLayout实现底部表单内部和活动。点击“显示扫描仪结果按钮”时,底部表单应向上滑动。我已经实现了所有必要的代码,但当按下按钮时,什么也没有发生 以下是主要活动代码 public class Dashboard extends AppCompatActivity{ private LinearLayout mBottomSheet; private BottomSheetBehavior mBottomSheetBehavior;

我目前正在使用coordinatorLayout实现底部表单内部和活动。点击“显示扫描仪结果按钮”时,底部表单应向上滑动。我已经实现了所有必要的代码,但当按下按钮时,什么也没有发生

以下是主要活动代码

public class Dashboard extends AppCompatActivity{

   private LinearLayout mBottomSheet;
    private BottomSheetBehavior mBottomSheetBehavior;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dashboard);


        mBottomSheet = findViewById(R.id.bottomSheetContainer);

        mBottomSheetBehavior = BottomSheetBehavior.from(mBottomSheet);


       Button buttonShow = findViewById(R.id.buttonShow);

        buttonShow.setOnClickListener(new  View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if(mBottomSheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED){
                    mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
                } else {
                    mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
                }

            }
        });

        mBottomSheetBehavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
            @Override
            public void onStateChanged(@NonNull View bottomSheet, int newState) {

            }

            @Override
            public void onSlide(@NonNull View bottomSheet, float slideOffset) {


            }
        });
下面是XML代码

    <?xml version="1.0" encoding="utf-8"?>
    <androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clickable="true"
        tools:context=".Dashboard">
    
    
        <androidx.coordinatorlayout.widget.CoordinatorLayout
            android:id="@+id/cord_main_content"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
    
    
            <include layout="@layout/layout_bottom_sheet" />
    
    
        </androidx.coordinatorlayout.widget.CoordinatorLayout>
    
    
        <Button
            android:id="@+id/buttonShow"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="Show Scanner results"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
    
            />
    
    
    
    
    
        <com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/bottom_navigation"
            android:layout_width="match_parent"
            android:layout_height="80dp"
            android:layout_alignParentBottom="true"
            android:layout_marginTop="651dp"
            android:background="?android:attr/windowBackground"
    
            app:itemIconTint="@drawable/selector"
            app:itemTextColor="@drawable/selector"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/cord_main_content"
            app:layout_constraintVertical_bias="1.0"
            app:menu="@menu/menu_navigation" />
    
    
    </androidx.constraintlayout.widget.ConstraintLayout>


Below is the XML code for the included layout_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"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/bottomSheetContainer"
    android:background="@drawable/bottom_sheet_background"
    android:orientation="vertical"
    app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
    app:behavior_hideable="true"

    >

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity = "center"
        android:padding="15dp"
        android:text="Scanned foods found"
        android:textColor="@color/colorSecondaryText"
        android:textSize="18sp"
        android:textStyle="bold"/>



        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:padding="5dp">



            <TextView
                android:id="@+id/text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:padding="12dp"
                android:text="Decoded Text"
                android:textColor="@color/colorPrimaryText"
                android:textSize="20sp"
                android:textStyle="bold"







   />
        </LinearLayout>

下面是包含的布局表的XML代码。