public static int getDefaultSize ( final int size , final int measureSpec ) { final int result ; final int specMode = MeasureSpec . getMode ( measureSpec ) ; final int specSize = MeasureSpec . getSize ( measureSpec ) ; switch ( specMode ) { case MeasureSpec . AT_MOST : result = Math . min ( size , specSize ) ; break ; case MeasureSpec . EXACTLY : result = specSize ; break ; default : result = size ; break ; } return result ; }
Utility to return a default size . Uses the supplied size if the MeasureSpec imposed no constraints . Will get larger if allowed by the MeasureSpec .