Skip to content

Commit a880085

Browse files
committed
Bugfixing: The text appears clipped when using setMinTextSize method
1 parent a71ebe7 commit a880085

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

AutoFitTextViewLibrary/src/com/lb/auto_fit_textview/AutoResizeTextView.java

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -204,18 +204,28 @@ private void reAdjust()
204204
adjustTextSize();
205205
}
206206

207-
private void adjustTextSize()
207+
private void adjustTextSize()
208208
{
209-
if(!_initiallized)
210-
return;
211-
final int startSize=(int)_minTextSize;
212-
final int heightLimit=getMeasuredHeight()-getCompoundPaddingBottom()-getCompoundPaddingTop();
213-
_widthLimit=getMeasuredWidth()-getCompoundPaddingLeft()-getCompoundPaddingRight();
214-
if(_widthLimit<=0)
215-
return;
216-
_availableSpaceRect.right=_widthLimit;
217-
_availableSpaceRect.bottom=heightLimit;
218-
super.setTextSize(TypedValue.COMPLEX_UNIT_PX,efficientTextSizeSearch(startSize,(int)_maxTextSize,_sizeTester,_availableSpaceRect));
209+
post(new Runnable() {
210+
@Override
211+
public void run() {
212+
if (!_initiallized)
213+
return;
214+
final int startSize = (int) _minTextSize;
215+
final int heightLimit = getMeasuredHeight() - getCompoundPaddingBottom() - getCompoundPaddingTop();
216+
_widthLimit = getMeasuredWidth() - getCompoundPaddingLeft() - getCompoundPaddingRight();
217+
if (_widthLimit <= 0)
218+
return;
219+
_availableSpaceRect.right = _widthLimit;
220+
_availableSpaceRect.bottom = heightLimit;
221+
// super.setTextSize(TypedValue.COMPLEX_UNIT_PX, efficientTextSizeSearch(startSize, (int) _maxTextSize, _sizeTester, _availableSpaceRect));
222+
superSetTextSize(startSize);
223+
}
224+
});
225+
}
226+
227+
private void superSetTextSize(int startSize) {
228+
super.setTextSize(TypedValue.COMPLEX_UNIT_PX, efficientTextSizeSearch(startSize, (int) _maxTextSize, _sizeTester, _availableSpaceRect));
219229
}
220230

221231
/**

0 commit comments

Comments
 (0)