private void calculateUsingTextSize(final float textSize){
  if (msText == null)   return;
  final float availableWidth;
  final float newTextSize;
  boolean updateDrawText=false;
  if (isClose(textSize,mfCollapsedTextSize)) {
    availableWidth=mCollapsedBounds.width();
    newTextSize=mfCollapsedTextSize;
    mScale=1f;
  }
 else {
    availableWidth=mExpandedBounds.width();
    newTextSize=mfExpandedTextSize;
    if (isClose(textSize,mfExpandedTextSize)) {
      mScale=1f;
    }
 else {
      mScale=textSize / mfExpandedTextSize;
    }
  }
  if (availableWidth > 0) {
    updateDrawText=(mCurrentTextSize != newTextSize) || mBoundsChanged || updateDrawText;
    mCurrentTextSize=newTextSize;
    mBoundsChanged=false;
  }
  if (mTextToDraw == null || updateDrawText) {
    mTextPaint.setTextSize(mCurrentTextSize);
    final CharSequence title=TextUtils.ellipsize(msText,mTextPaint,availableWidth,TextUtils.TruncateAt.END);
    if (!TextUtils.equals(title,mTextToDraw)) {
      mTextToDraw=title;
    }
  }
}

private void calculateUsingTextSize ( final float textSize ) { if ( msText == null ) return ; final float availableWidth ; final float newTextSize ; boolean updateDrawText = false ; if ( isClose ( textSize , mfCollapsedTextSize ) ) { availableWidth = mCollapsedBounds . width ( ) ; newTextSize = mfCollapsedTextSize ; mScale = 1f ; } else { availableWidth = mExpandedBounds . width ( ) ; newTextSize = mfExpandedTextSize ; if ( isClose ( textSize , mfExpandedTextSize ) ) { mScale = 1f ; } else { mScale = textSize / mfExpandedTextSize ; } } if ( availableWidth > 0 ) { updateDrawText = ( mCurrentTextSize != newTextSize ) || mBoundsChanged || updateDrawText ; mCurrentTextSize = newTextSize ; mBoundsChanged = false ; } if ( mTextToDraw == null || updateDrawText ) { mTextPaint . setTextSize ( mCurrentTextSize ) ; final CharSequence title = TextUtils . ellipsize ( msText , mTextPaint , availableWidth , TextUtils . TruncateAt . END ) ; if ( ! TextUtils . equals ( title , mTextToDraw ) ) { mTextToDraw = title ; } } }
the font size is scaled to collapsed / expanded text size if its anywhere close to these values . else , the canvas is scaled in draw with the factor calculated here . adapted from collapsingtexthelper , aosp .
