code: public void adaptHeightToChildren() {
          DividableGridAdapter adapter = (DividableGridAdapter) getAdapter();
  
          if (adapter != null) {
              int height = getPaddingTop() + getPaddingBottom();
  
              for (int i = 0; i < adapter.getCount(); i += adapter.getColumnCount()) {
                  AbstractItem item = adapter.getItem(i);
  
                  if (item instanceof Divider) {
                      height += getResources().getDimensionPixelSize(
                              TextUtils.isEmpty(item.getTitle()) ?
                                      R.dimen.bottom_sheet_divider_height :
                                      R.dimen.bottom_sheet_divider_title_height);
                  } else {
                      height += getResources().getDimensionPixelSize(
                              adapter.getStyle() == BottomSheet.Style.GRID ?
                                      R.dimen.bottom_sheet_grid_item_size :
                                      R.dimen.bottom_sheet_list_item_height);
                  }
              }
  
              ViewGroup.LayoutParams params = getLayoutParams();
              params.height = height;
              setLayoutParams(params);
              requestLayout();
          }
      }
docs: Adapts the height of the grid view to the height of its children.