diff --git a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java index 627538bc..60fc01b5 100755 --- a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java +++ b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java @@ -26,6 +26,7 @@ import android.text.TextWatcher; import android.text.method.TransformationMethod; import android.util.AttributeSet; +import android.util.Log; import android.util.TypedValue; import android.view.Gravity; import android.view.MotionEvent; @@ -1420,7 +1421,7 @@ protected void onDraw(@NonNull Canvas canvas) { } // draw the bottom ellipsis - if (hasFocus() && singleLineEllipsis && getScrollX() != 0) { + if (hasFocus() && singleLineEllipsis && textReachedEndOfEditText()) { paint.setColor(isInternalValid() ? primaryColor : errorColor); float startY = lineStartY + bottomSpacing; int ellipsisStartX; @@ -1439,6 +1440,10 @@ protected void onDraw(@NonNull Canvas canvas) { super.onDraw(canvas); } + private boolean textReachedEndOfEditText() { + return getPaint().measureText(getText().toString()) > getWidth(); + } + private boolean shouldDrawBottomText() { if (tempErrorText != null) { diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index ef55f9d9..1e7725c5 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -172,6 +172,23 @@ android:text="Touch The Ellipsis And See What Happens. Touch The Ellipsis And See What Happens." app:met_singleLineEllipsis="true" /> + + + + +