code: @Override
      protected void onLayout(boolean changed, int l, int t, int r, int b) {
          super.onLayout(changed, l, t, r, b);
  
          if (mAdjustViewSize) {
              if (!(getParent() instanceof RelativeLayout)) {
                  throw new IllegalStateException("Only RelativeLayout is supported as parent of this view");
              }
  
              final int sWidth = ScreenHelper.getScreenWidth(getContext());
              final int sHeight = ScreenHelper.getScreenHeight(getContext());
  
              RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) getLayoutParams();
  
              params.width = (int) (sWidth * mButtonMenu.getMainButtonSize());
              params.height = (int) (sWidth * mButtonMenu.getMainButtonSize());
              params.setMargins(0, 0, 0, (int) (sHeight * mButtonMenu.getBottomPadding()));
          }
      }
docs: Adjusts size of this view to match the underlying button menu. This allows
  a smooth transition between this view and the close button behind it.