private static int clampSize ( int size , int spec ) { int specMode = MeasureSpec . getMode ( spec ) ; int specSize = MeasureSpec . getSize ( spec ) ; switch ( specMode ) { case MeasureSpec . EXACTLY : { return specSize ; } case MeasureSpec . AT_MOST : { return Math . min ( size , specSize ) ; } case MeasureSpec . UNSPECIFIED : default : { return size ; } } }
Clamp the size to the measure spec .