Fix bottomSheet height with expandableListView

This commit is contained in:
Chumva 2018-11-30 18:49:45 +02:00
parent c840cedc0f
commit 8193ed11d2
3 changed files with 11 additions and 2 deletions

View file

@ -179,7 +179,11 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
public void onGlobalLayout() { public void onGlobalLayout() {
final View contentView = useScrollableItemsContainer() ? mainView.findViewById(R.id.scroll_view) : itemsContainer; final View contentView = useScrollableItemsContainer() ? mainView.findViewById(R.id.scroll_view) : itemsContainer;
if (contentView.getHeight() > contentHeight) { if (contentView.getHeight() > contentHeight) {
contentView.getLayoutParams().height = contentHeight; if (useScrollableItemsContainer()) {
contentView.getLayoutParams().height = contentHeight;
} else {
contentView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT;
}
contentView.requestLayout(); contentView.requestLayout();
} }
@ -187,6 +191,9 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
boolean showTopShadow = screenHeight - statusBarHeight - mainView.getHeight() >= AndroidUtils.dpToPx(activity, 8); boolean showTopShadow = screenHeight - statusBarHeight - mainView.getHeight() >= AndroidUtils.dpToPx(activity, 8);
if (AndroidUiHelper.isOrientationPortrait(activity)) { if (AndroidUiHelper.isOrientationPortrait(activity)) {
mainView.setBackgroundResource(showTopShadow ? getPortraitBgResId() : getBgColorId()); mainView.setBackgroundResource(showTopShadow ? getPortraitBgResId() : getBgColorId());
if (!useScrollableItemsContainer() && !showTopShadow) {
mainView.setPadding(0, 0, 0, 0);
}
} else { } else {
mainView.setBackgroundResource(showTopShadow ? getLandscapeTopsidesBgResId() : getLandscapeSidesBgResId()); mainView.setBackgroundResource(showTopShadow ? getLandscapeTopsidesBgResId() : getLandscapeSidesBgResId());
} }

View file

@ -188,7 +188,6 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
counter++; counter++;
} }
} }
private void populateImpassableRoadsTypes() { private void populateImpassableRoadsTypes() {

View file

@ -182,6 +182,7 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
if (adapter != null) { if (adapter != null) {
adapter.contentItem = getAdapterContentItems(); adapter.contentItem = getAdapterContentItems();
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
setupHeightAndBackground(getView());
} }
} }
@ -309,6 +310,7 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
} }
if (isChecked) { if (isChecked) {
expListView.expandGroup(groupPosition); expListView.expandGroup(groupPosition);
setupHeightAndBackground(getView());
} }
} }
}); });
@ -322,6 +324,7 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
} else { } else {
expListView.expandGroup(groupPosition); expListView.expandGroup(groupPosition);
} }
setupHeightAndBackground(getView());
} }
} }
}); });