Skip to content

Commit 338d326

Browse files
leticiarossipekingme
authored andcommitted
[TextInputLayout] Fixing label misalignment in legacy text fields when there is prefix/suffix
Resolves #700 PiperOrigin-RevId: 289080344
1 parent 94cd734 commit 338d326

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

lib/java/com/google/android/material/textfield/TextInputLayout.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2349,19 +2349,19 @@ private Rect calculateCollapsedTextBounds(@NonNull Rect rect) {
23492349
bounds.right = rect.right - editText.getPaddingRight();
23502350
return bounds;
23512351
case BOX_BACKGROUND_FILLED:
2352-
bounds.left = getFilledLabelLeftBound(rect.left, isRtl);
2352+
bounds.left = getLabelLeftBoundAlightWithPrefix(rect.left, isRtl);
23532353
bounds.top = rect.top + boxCollapsedPaddingTopPx;
2354-
bounds.right = getFilledLabelRightBound(rect.right, isRtl);
2354+
bounds.right = getLabelRightBoundAlignedWithSuffix(rect.right, isRtl);
23552355
return bounds;
23562356
default:
2357-
bounds.left = rect.left + editText.getCompoundPaddingLeft();
2357+
bounds.left = getLabelLeftBoundAlightWithPrefix(rect.left, isRtl);
23582358
bounds.top = getPaddingTop();
2359-
bounds.right = rect.right - editText.getCompoundPaddingRight();
2359+
bounds.right = getLabelRightBoundAlignedWithSuffix(rect.right, isRtl);
23602360
return bounds;
23612361
}
23622362
}
23632363

2364-
private int getFilledLabelLeftBound(int rectLeft, boolean isRtl) {
2364+
private int getLabelLeftBoundAlightWithPrefix(int rectLeft, boolean isRtl) {
23652365
int left = rectLeft + editText.getCompoundPaddingLeft();
23662366
if (prefixText != null && !isRtl) {
23672367
// Label should be vertically aligned with prefix
@@ -2370,7 +2370,7 @@ private int getFilledLabelLeftBound(int rectLeft, boolean isRtl) {
23702370
return left;
23712371
}
23722372

2373-
private int getFilledLabelRightBound(int rectRight, boolean isRtl) {
2373+
private int getLabelRightBoundAlignedWithSuffix(int rectRight, boolean isRtl) {
23742374
int right = rectRight - editText.getCompoundPaddingRight();
23752375
if (prefixText != null && isRtl) {
23762376
// Label should be vertically aligned with prefix if in RTL

0 commit comments

Comments
 (0)