Skip to content

Commit 42ca158

Browse files
Merge pull request #26 from mpekalski/master
check for textAllCaps
2 parents ddd35ca + 29ab484 commit 42ca158

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public AutoResizeTextView(final Context context, final AttributeSet attrs) {
5050

5151
public AutoResizeTextView(final Context context, final AttributeSet attrs, final int defStyle) {
5252
super(context, attrs, defStyle);
53+
5354
// using the minimal recommended font size
5455
_minTextSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12, getResources().getDisplayMetrics());
5556
_maxTextSize = getTextSize();
@@ -65,7 +66,13 @@ public AutoResizeTextView(final Context context, final AttributeSet attrs, final
6566
@Override
6667
public int onTestSize(final int suggestedSize, final RectF availableSPace) {
6768
_paint.setTextSize(suggestedSize);
68-
final String text = getText().toString();
69+
final TransformationMethod transformationMethod = getTransformationMethod();
70+
final String text;
71+
if (transformationMethod != null)
72+
text = transformationMethod.getTransformation(getText(), AutoResizeTextView.this).toString();
73+
else
74+
text = getText().toString();
75+
6976
final boolean singleLine = getMaxLines() == 1;
7077
if (singleLine) {
7178
textRect.bottom = _paint.getFontSpacing();
@@ -93,6 +100,12 @@ public int onTestSize(final int suggestedSize, final RectF availableSPace) {
93100
_initialized = true;
94101
}
95102

103+
@Override
104+
public void setAllCaps(boolean allCaps) {
105+
super.setAllCaps(allCaps);
106+
adjustTextSize();
107+
}
108+
96109
@Override
97110
public void setTypeface(final Typeface tf) {
98111
super.setTypeface(tf);

0 commit comments

Comments
 (0)