我想设置底页对话框片段的窥视高度,但是我无法在片段中定义底页行为,有人可以帮助我吗?
getDialog()在oncreateview方法中返回null
SpinnerCity.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
State cityDetails = statesList.get(position); // here do like this
List<String> cityList = cityDetails.getCities();
ArrayAdapter citiesAdapter = new ArrayAdapter<>(this,
R.layout.city_list, R.id.citySpinnerText, cityList);
SpinnerArea.setAdapter(citiesAdapter);
// SpinnerArea.setSelected(String city); // Remove this, no use
}
答案 0 :(得分:0)
您需要在onCreateDialog中调用它
这是代码:
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
BottomSheetDialog dialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);
dialog.setOnShowListener(dialogInterface -> {
BottomSheetDialog d = (BottomSheetDialog) dialogInterface;
FrameLayout bottomSheet = (FrameLayout) d.findViewById(android.support.design.R.id.design_bottom_sheet);
BottomSheetBehavior bsb = BottomSheetBehavior
.from(bottomSheet);
bsb.setPeekHeight(56/*Your height*/);
});
return dialog;
}