private int measureHeight(int measureSpec){
  int specMode=MeasureSpec.getMode(measureSpec);
  int specSize=MeasureSpec.getSize(measureSpec);
  int result;
  if (specMode == MeasureSpec.EXACTLY) {
    result=specSize;
  }
 else {
    final int height;
    if (layoutHeight == ViewGroup.LayoutParams.WRAP_CONTENT) {
      height=dpToPx(getContext(),DEFAULT_HEIGHT_IN_DP);
    }
 else     if (layoutHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
      height=getMeasuredHeight();
    }
 else {
      height=layoutHeight;
    }
    result=height + getPaddingTop() + getPaddingBottom()+ (2 * DEFAULT_PAINT_STROKE_WIDTH);
    if (specMode == MeasureSpec.AT_MOST) {
      result=Math.min(result,specSize);
    }
  }
  return result;
}

private int measureHeight ( int measureSpec ) { int specMode = MeasureSpec . getMode ( measureSpec ) ; int specSize = MeasureSpec . getSize ( measureSpec ) ; int result ; if ( specMode == MeasureSpec . EXACTLY ) { result = specSize ; } else { final int height ; if ( layoutHeight == ViewGroup . LayoutParams . WRAP_CONTENT ) { height = dpToPx ( getContext ( ) , DEFAULT_HEIGHT_IN_DP ) ; } else if ( layoutHeight == ViewGroup . LayoutParams . MATCH_PARENT ) { height = getMeasuredHeight ( ) ; } else { height = layoutHeight ; } result = height + getPaddingTop ( ) + getPaddingBottom ( ) + ( 2 * DEFAULT_PAINT_STROKE_WIDTH ) ; if ( specMode == MeasureSpec . AT_MOST ) { result = Math . min ( result , specSize ) ; } } return result ; }
measures height according to the passed measure spec
