code: @Override
      protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
          ViewGroup.LayoutParams params = getLayoutParams();
          boolean customMeasure = false;
          int newHeight = MeasureSpec.getSize(heightMeasureSpec);
          int newWidth = MeasureSpec.getSize(widthMeasureSpec);
          if (MeasureSpec.getMode(heightMeasureSpec) != MeasureSpec.EXACTLY &&
                  params.height == ViewGroup.LayoutParams.WRAP_CONTENT) {
              newHeight = getPresetSizeInPixels(true); // Default to a preset size
              heightMeasureSpec = MeasureSpec.makeMeasureSpec(newHeight, MeasureSpec.EXACTLY);
              customMeasure = true;
          }
  
          if (MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.EXACTLY &&
                  params.width == ViewGroup.LayoutParams.WRAP_CONTENT) {
              newWidth = getPresetSizeInPixels(true); // Default to a preset size
              widthMeasureSpec = MeasureSpec.makeMeasureSpec(newWidth, MeasureSpec.EXACTLY);
              customMeasure = true;
          }
  
          if (customMeasure) {
              // Since we are providing custom dimensions, we need to handle the measure
              // phase from here
              setMeasuredDimension(newWidth, newHeight);
              measureChildren(widthMeasureSpec, heightMeasureSpec);
          } else {
              // Rely on FrameLayout to do the right thing
              super.onMeasure(widthMeasureSpec, heightMeasureSpec);
          }
      }
docs: Overriding onMeasure to handle the case where WRAP_CONTENT might be
  specified in the layout. Since we don't know the dimensions of the profile
  photo, we need to handle this case specifically.
  <p/>
  The approach is to default to a NORMAL sized amount of space in the case that
  a preset size is not specified. This logic is applied to both width and height