code: static int measureViewHeight(@Nullable View view) {
          int height = 0;
          if (view != null && view.isShown()) {
              ViewGroup.MarginLayoutParams modeSelectionParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
              height = view.getMeasuredHeight() + modeSelectionParams.topMargin + modeSelectionParams.bottomMargin + view.getPaddingTop() + view.getPaddingBottom();
          }
          return height;
      }
docs: Measures the height of a view considering the margins and its visibility.
  
  @param view to measure the height.