diff --git a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java index 51d9d7c8..d009f0cc 100755 --- a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java +++ b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java @@ -1283,6 +1283,14 @@ private ObjectAnimator getBottomLinesAnimator(float destBottomLines) { return bottomLinesAnimator; } + void renderClearButton() { + if (hasFocus() && showClearButton && !TextUtils.isEmpty(getText()) && isEnabled()) { + showClearButton(); + } else { + hideClearButton(); + } + } + @Override protected void onDraw(@NonNull Canvas canvas) { @@ -1305,10 +1313,7 @@ protected void onDraw(@NonNull Canvas canvas) { canvas.drawBitmap(icon, iconRight, iconTop, paint); } - // draw the clear button - if (hasFocus() && showClearButton && !TextUtils.isEmpty(getText()) && isEnabled()) { - showClearButton(); - } + renderClearButton(); // draw the underline if (!hideUnderline) {