code: @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
      final int count = getChildCount();
  
      final int parentLeft = getPaddingLeft();
      final int parentWidth = right - left - parentLeft - getPaddingRight();
  
      int childTop = getPaddingTop();
  
      for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == View.GONE) {
          continue;
        }
  
        final int width = child.getMeasuredWidth();
        final int height = child.getMeasuredHeight();
  
        int delta = (parentWidth - width) / 2;
        int childLeft = parentLeft + delta;
  
        child.layout(childLeft, childTop, childLeft + width, childTop + height);
  
        childTop += height;
      }
    }
docs: {@inheritDoc}