v7/appcompat/src/main/java/androidx/appcompat/widget/AppCompatTextViewAutoSizeHelper.java
@RestrictTo(LIBRARY_GROUP)
    void autoSizeText() {
        if (!isAutoSizeEnabled()) {
            return;
        }

        if (mNeedsAutoSizeText) {
            if (mTextView.getMeasuredHeight() <= 0 || mTextView.getMeasuredWidth() <= 0) {
                return;
            }

            final boolean horizontallyScrolling = invokeAndReturnWithDefault(
                    mTextView, "getHorizontallyScrolling", false);
            final int availableWidth = horizontallyScrolling
                    ? VERY_WIDE
                    : mTextView.getMeasuredWidth() - mTextView.getTotalPaddingLeft()
                            - mTextView.getTotalPaddingRight();
            final int availableHeight = mTextView.getHeight() - mTextView.getCompoundPaddingBottom()
                    - mTextView.getCompoundPaddingTop();

            if (availableWidth <= 0 || availableHeight <= 0) {
                return;
            }

            synchronized (TEMP_RECTF) {
                TEMP_RECTF.setEmpty();
                TEMP_RECTF.right = availableWidth;
                TEMP_RECTF.bottom = availableHeight;
                final float optimalTextSize = findLargestTextSizeWhichFits(TEMP_RECTF);
                if (optimalTextSize != mTextView.getTextSize()) {
                    setTextSizeInternal(TypedValue.COMPLEX_UNIT_PX, optimalTextSize);
                }
            }
        }
        // Always try to auto-size if enabled. Functions that do not want to trigger auto-sizing
        // after the next layout pass should set this to false.
        mNeedsAutoSizeText = true;
    }
/**
     * Automatically computes and sets the text size.
     *
     * @hide
     */
Automatically computes and sets the text size.
@hide
Automatically computes and sets the text size . @hide
@RestrictTo(LIBRARY_GROUP)
    void autoSizeText() {
        if (!isAutoSizeEnabled()) {
            return;
        }
        if (mNeedsAutoSizeText) {
            if (mTextView.getMeasuredHeight() <= 0 || mTextView.getMeasuredWidth() <= 0) {
                return;
            }
            final boolean horizontallyScrolling = invokeAndReturnWithDefault(
                    mTextView, "getHorizontallyScrolling", false);
            final int availableWidth = horizontallyScrolling
                    ? VERY_WIDE
                    : mTextView.getMeasuredWidth() - mTextView.getTotalPaddingLeft()
                            - mTextView.getTotalPaddingRight();
            final int availableHeight = mTextView.getHeight() - mTextView.getCompoundPaddingBottom()
                    - mTextView.getCompoundPaddingTop();
            if (availableWidth <= 0 || availableHeight <= 0) {
                return;
            }
            synchronized (TEMP_RECTF) {
                TEMP_RECTF.setEmpty();
                TEMP_RECTF.right = availableWidth;
                TEMP_RECTF.bottom = availableHeight;
                final float optimalTextSize = findLargestTextSizeWhichFits(TEMP_RECTF);
                if (optimalTextSize != mTextView.getTextSize()) {
                    setTextSizeInternal(TypedValue.COMPLEX_UNIT_PX, optimalTextSize);
                }
            }
        }
        mNeedsAutoSizeText = true;
    }
@ RestrictTo ( LIBRARY_GROUP ) void autoSizeText ( ) { if ( ! isAutoSizeEnabled ( ) ) { return ; } if ( mNeedsAutoSizeText ) { if ( mTextView . getMeasuredHeight ( ) <= 0 || mTextView . getMeasuredWidth ( ) <= 0 ) { return ; } final boolean horizontallyScrolling = invokeAndReturnWithDefault ( mTextView , "getHorizontallyScrolling" , false ) ; final int availableWidth = horizontallyScrolling ? VERY_WIDE : mTextView . getMeasuredWidth ( ) - mTextView . getTotalPaddingLeft ( ) - mTextView . getTotalPaddingRight ( ) ; final int availableHeight = mTextView . getHeight ( ) - mTextView . getCompoundPaddingBottom ( ) - mTextView . getCompoundPaddingTop ( ) ; if ( availableWidth <= 0 || availableHeight <= 0 ) { return ; } synchronized ( TEMP_RECTF ) { TEMP_RECTF . setEmpty ( ) ; TEMP_RECTF . right = availableWidth ; TEMP_RECTF . bottom = availableHeight ; final float optimalTextSize = findLargestTextSizeWhichFits ( TEMP_RECTF ) ; if ( optimalTextSize != mTextView . getTextSize ( ) ) { setTextSizeInternal ( TypedValue . COMPLEX_UNIT_PX , optimalTextSize ) ; } } } mNeedsAutoSizeText = true ; }
Automatically computes and sets the text size.
Automatically computes and sets the text size .
// Always try to auto-size if enabled. Functions that do not want to trigger auto-sizing // after the next layout pass should set this to false.