在使用 Android 底部表单时,可能需要使其高度与父控件的高度相关。可以使用以下代码实现:
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet); bottomSheetBehavior.setPeekHeight(mainContent.getHeight());
Button buttonShowBottomSheet = findViewById(R.id.button_show_bottom_sheet); buttonShow