question: @ Override protected void onMeasure ( int widthMeasureSpec , int heightMeasureSpec ) { int widthSize = MeasureSpec . getSize ( widthMeasureSpec ) ; int widthMode = MeasureSpec . getMode ( widthMeasureSpec ) ; int width ; int heightSize = MeasureSpec . getSize ( heightMeasureSpec ) ; int heightMode = MeasureSpec . getMode ( heightMeasureSpec ) ; int height ; final int count = getChildCount ( ) ; int maxChildWidth = 0 ; for ( int i = 0 ; i < count ; i ++ ) { View child = getChildAt ( i ) ; measureChild ( child , widthMeasureSpec , heightMeasureSpec ) ; } for ( int i = 0 ; i < mMenuItems . size ( ) ; i ++ ) { FloatingActionButton fab = mMenuItems . get ( i ) ; TextView label = mMenuItemLabels . get ( i ) ; maxChildWidth = Math . max ( maxChildWidth , label . getMeasuredWidth ( ) + fab . getMeasuredWidth ( ) ) ; } maxChildWidth = Math . max ( mMenuButton . getMeasuredWidth ( ) , maxChildWidth ) ; if ( widthMode == MeasureSpec . EXACTLY ) { width = widthSize ; } else { width = maxChildWidth + 30 ; } if ( heightMode == MeasureSpec . EXACTLY ) { height = heightSize ; } else { int heightSum = 0 ; for ( int i = 0 ; i < count ; i ++ ) { View child = getChildAt ( i ) ; heightSum += child . getMeasuredHeight ( ) ; } height = heightSum + 20 ; } setMeasuredDimension ( resolveSize ( width , widthMeasureSpec ) , resolveSize ( height , heightMeasureSpec ) ) ; }
target:  Handles the measuring of the FAM, and sets the size according to the number of children.