Add the ability to set maximum height for bottom sheet menus
This commit is contained in:
parent
c367139f6a
commit
775bbe1e21
1 changed files with 13 additions and 3 deletions
|
@ -158,9 +158,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
|
||||
final int screenHeight = AndroidUtils.getScreenHeight(activity);
|
||||
final int statusBarHeight = AndroidUtils.getStatusBarHeight(activity);
|
||||
final int availableHeight = screenHeight - statusBarHeight - AndroidUtils.getNavBarHeight(activity)
|
||||
- AndroidUtils.dpToPx(getContext(), 1) // divider height
|
||||
- getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height); // bottom row height
|
||||
final int availableHeight = getAvailableHeight(screenHeight, statusBarHeight);
|
||||
|
||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
|
@ -189,6 +187,18 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
});
|
||||
}
|
||||
|
||||
private int getAvailableHeight(int screenHeight, int statusBarHeight) {
|
||||
int maxHeight = getMaximumHeight();
|
||||
return maxHeight != -1 ? maxHeight
|
||||
: screenHeight - statusBarHeight - AndroidUtils.getNavBarHeight(getContext())
|
||||
- AndroidUtils.dpToPx(getContext(), 1) // divider height
|
||||
- getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
||||
}
|
||||
|
||||
protected int getMaximumHeight() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected boolean useScrollableItemsContainer() {
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue