【发布时间】:2017-06-14 20:53:56
【问题描述】:
我正在使用 BottomSheetDialogFragment。一切都很完美,但我有一个问题。我无法更改我的 BottomSheetDialogFragment 中的 PeekHeight。这是我的来源
public class BottomSheet3DialogFragment extends BottomSheetDialogFragment {
private BottomSheetBehavior mBottomSheetBehavior2;
private BottomSheetBehavior.BottomSheetCallback
mBottomSheetBehaviorCallback = new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (newState == BottomSheetBehavior.STATE_HIDDEN) {
dismiss();
}
mBottomSheetBehavior2= BottomSheetBehavior.from(bottomSheet);
if(mBottomSheetBehavior2!=null)
mBottomSheetBehavior2.setPeekHeight(20);
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
}
};
@Override
public void setupDialog(final Dialog dialog, int style) {
super.setupDialog(dialog, style);
View contentView = View.inflate(getContext(), R.layout.fragment_bottomsheet3, null);
dialog.setContentView(contentView);
}
}
mButton3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
BottomSheet3DialogFragment bottomSheetDialogFragment = new BottomSheet3DialogFragment();
bottomSheetDialogFragment.show(getSupportFragmentManager(), bottomSheetDialogFragment.getTag());
}
});
是否可以在我的 Fragment 中更改 PeekHeight?如果有人知道解决方案,请帮助我 谢谢
【问题讨论】:
标签: android material-design android-support-design