在使用BottomSheetDialog滑动消失后,再次点击显示的时候,没有成功显示,BottomSheetBehavior被设置成了隐藏模式,需要在dismiss()的监听中重新设置下状态就可以了
View bottomSheetView = getLayoutInflater().inflate(R.layout.bottomsheetdialog_layout, null);
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(MainActivity.this);
bottomSheetDialog.setContentView(bottomSheetView);
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from((View) bottomSheetView.getParent());
bottomSheetDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
textPrompt1.setText("OnDismiss");
}
});