code: static int measureChildForCells(View child, int cellSize, int cellsRemaining,
              int parentHeightMeasureSpec, int parentHeightPadding) {
          final LayoutParams lp = (LayoutParams) child.getLayoutParams();
  
          final int childHeightSize = MeasureSpec.getSize(parentHeightMeasureSpec) -
                  parentHeightPadding;
          final int childHeightMode = MeasureSpec.getMode(parentHeightMeasureSpec);
          final int childHeightSpec = MeasureSpec.makeMeasureSpec(childHeightSize, childHeightMode);
  
          int cellsUsed = 0;
          if (cellsRemaining > 0) {
              final int childWidthSpec = MeasureSpec.makeMeasureSpec(
                      cellSize * cellsRemaining, MeasureSpec.AT_MOST);
              child.measure(childWidthSpec, childHeightSpec);
  
              final int measuredWidth = child.getMeasuredWidth();
              cellsUsed = measuredWidth / cellSize;
              if (measuredWidth % cellSize != 0) cellsUsed++;
          }
  
          final ActionMenuItemView itemView = child instanceof ActionMenuItemView ?
                  (ActionMenuItemView) child : null;
          final boolean expandable = !lp.isOverflowButton && itemView != null && itemView.hasText();
          lp.expandable = expandable;
  
          lp.cellsUsed = cellsUsed;
          final int targetWidth = cellsUsed * cellSize;
          child.measure(MeasureSpec.makeMeasureSpec(targetWidth, MeasureSpec.EXACTLY),
                  childHeightSpec);
          return cellsUsed;
      }
docs: Measure a child view to fit within cell-based formatting. The child's width
  will be measured to a whole multiple of cellSize.
  
  <p>Sets the expandable and cellsUsed fields of LayoutParams.
  
  @param child Child to measure
  @param cellSize Size of one cell
  @param cellsRemaining Number of cells remaining that this view can expand to fill
  @param parentHeightMeasureSpec MeasureSpec used by the parent view
  @param parentHeightPadding Padding present in the parent view
  @return Number of cells this child was measured to occupy