code: @Override
      protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
          final int height = getDefaultSize(getSuggestedMinimumHeight(), heightMeasureSpec);
          final int width = getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec);
          final int min = Math.min(width, height);
          setMeasuredDimension(min, min);
          float highStroke = strokeWidth > backgroundStrokeWidth ? strokeWidth : backgroundStrokeWidth;
          rectF.set(0 + highStroke / 2, 0 + highStroke / 2, min - highStroke / 2, min - highStroke / 2);
      }
docs: region Mesure Method