private int calculateLayoutWidth(int widthSize,int mode){
  initResourcesIfNecessary();
  itemsLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
  itemsLayout.measure(MeasureSpec.makeMeasureSpec(widthSize,MeasureSpec.UNSPECIFIED),MeasureSpec.makeMeasureSpec(0,MeasureSpec.UNSPECIFIED));
  int width=itemsLayout.getMeasuredWidth();
  if (mode == MeasureSpec.EXACTLY) {
    width=widthSize;
  }
 else {
    width+=2 * PADDING;
    width=Math.max(width,getSuggestedMinimumWidth());
    if (mode == MeasureSpec.AT_MOST && widthSize < width) {
      width=widthSize;
    }
  }
  itemsLayout.measure(MeasureSpec.makeMeasureSpec(width - 2 * PADDING,MeasureSpec.EXACTLY),MeasureSpec.makeMeasureSpec(0,MeasureSpec.UNSPECIFIED));
  return width;
}

private int calculateLayoutWidth ( int widthSize , int mode ) { initResourcesIfNecessary ( ) ; itemsLayout . setLayoutParams ( new LayoutParams ( LayoutParams . WRAP_CONTENT , LayoutParams . WRAP_CONTENT ) ) ; itemsLayout . measure ( MeasureSpec . makeMeasureSpec ( widthSize , MeasureSpec . UNSPECIFIED ) , MeasureSpec . makeMeasureSpec ( 0 , MeasureSpec . UNSPECIFIED ) ) ; int width = itemsLayout . getMeasuredWidth ( ) ; if ( mode == MeasureSpec . EXACTLY ) { width = widthSize ; } else { width += 2 * PADDING ; width = Math . max ( width , getSuggestedMinimumWidth ( ) ) ; if ( mode == MeasureSpec . AT_MOST && widthSize < width ) { width = widthSize ; } } itemsLayout . measure ( MeasureSpec . makeMeasureSpec ( width - 2 * PADDING , MeasureSpec . EXACTLY ) , MeasureSpec . makeMeasureSpec ( 0 , MeasureSpec . UNSPECIFIED ) ) ; return width ; }
calculates control width and creates text layouts
