如何使 bottomSheet 占据屏幕的整个高度?设置窥视高度无效。
任何帮助,将不胜感激。
bottomSheetDialogFragment.getDialog().setOnShowListener((dialog) ->
{
final BottomSheetDialog bottomSheetDialog = (BottomSheetDialog)dialog;
final FrameLayout bottomSheet = bottomSheetDialog.findViewById(R.id.design_bottom_sheet);
if (bottomSheet != null)
{
final BottomSheetBehavior<View> behavior = BottomSheetBehavior.from(bottomSheet);
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
behavior.setPeekHeight(30000); // no effect, bottom sheet does not span entire height of screen
}
});
底页布局
<?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:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
<!-- rest of layout not shown -->
<FrameLayout
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/bottomSheetHandle"
tools:layout_height="48dp" />
</androidx.constraintlayout.widget.ConstraintLayout>