Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f730651a authored by Andrei Stingaceanu's avatar Andrei Stingaceanu
Browse files

AutoSize TextView - take horizontalScrolling into account

When passing the characteristics of the current TextView
to the StaticLayout for auto-size measurements also take
the horizontallyScrolling into account similarly with how
the actual measurements are done (@ TextView#onMeasure).

Bug: 37254477
Test: cts-tradefed run cts-dev -m CtsWidgetTestCases -t\
      android.widget.cts.TextViewTest

Change-Id: I44b85e77d9b1770f188a0f59f103e3fda284e97a
parent cf7cb9c9
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -8196,9 +8196,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        mTempTextPaint.set(getPaint());
        mTempTextPaint.setTextSize(suggestedSizeInPx);

        final int availableWidth = mHorizontallyScrolling
                ? VERY_WIDE
                : getMeasuredWidth() - getTotalPaddingLeft() - getTotalPaddingRight();
        final StaticLayout.Builder layoutBuilder = StaticLayout.Builder.obtain(
                text, 0, text.length(),  mTempTextPaint,
                getMeasuredWidth() - getTotalPaddingLeft() - getTotalPaddingRight());
                text, 0, text.length(),  mTempTextPaint, availableWidth);

        layoutBuilder.setAlignment(getLayoutAlignment())
                .setLineSpacing(getLineSpacingExtra(), getLineSpacingMultiplier())