From c3e5dcd228c0a1f61083a492ab7d2d98dde5f8a8 Mon Sep 17 00:00:00 2001 From: bolein Date: Wed, 16 Mar 2016 11:55:59 +0200 Subject: [PATCH 1/3] fix wrong alpha evaluation --- .../java/com/rengwuxian/materialedittext/MaterialEditText.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java index 77a84646..7096a3ba 100755 --- a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java +++ b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java @@ -1379,7 +1379,7 @@ protected void onDraw(@NonNull Canvas canvas) { int floatingLabelStartY = (int) (innerPaddingTop + floatingLabelTextSize + floatingLabelPadding - distance * (floatingLabelAlwaysShown ? 1 : floatingLabelFraction) + getScrollY()); // calculate the alpha - int alpha = ((int) ((floatingLabelAlwaysShown ? 1 : floatingLabelFraction) * 0xff * (0.74f * focusFraction * (isEnabled() ? 1 : 0) + 0.26f) * (floatingLabelTextColor != -1 ? 1 : Color.alpha(floatingLabelTextColor) / 256f))); + int alpha = ((int) ((floatingLabelAlwaysShown ? 1 : floatingLabelFraction) * 0xff * (0.74f * floatingLabelFraction * (isEnabled() ? 1 : 0) + 0.26f) * (floatingLabelTextColor != -1 ? 1 : Color.alpha(floatingLabelTextColor) / 256f))); textPaint.setAlpha(alpha); // draw the floating label From fa7836999e5fa128f649886d57180c3e76758295 Mon Sep 17 00:00:00 2001 From: bolein Date: Wed, 16 Mar 2016 14:32:30 +0200 Subject: [PATCH 2/3] treat origin alpha --- .../java/com/rengwuxian/materialedittext/MaterialEditText.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java index 7096a3ba..83fe95fe 100755 --- a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java +++ b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java @@ -1379,7 +1379,7 @@ protected void onDraw(@NonNull Canvas canvas) { int floatingLabelStartY = (int) (innerPaddingTop + floatingLabelTextSize + floatingLabelPadding - distance * (floatingLabelAlwaysShown ? 1 : floatingLabelFraction) + getScrollY()); // calculate the alpha - int alpha = ((int) ((floatingLabelAlwaysShown ? 1 : floatingLabelFraction) * 0xff * (0.74f * floatingLabelFraction * (isEnabled() ? 1 : 0) + 0.26f) * (floatingLabelTextColor != -1 ? 1 : Color.alpha(floatingLabelTextColor) / 256f))); + int alpha = ((int) ((floatingLabelAlwaysShown ? 1 : floatingLabelFraction) * (0.74f * floatingLabelFraction * (isEnabled() ? 1 : 0) + 0.26f) * Color.alpha(floatingLabelTextColor))); textPaint.setAlpha(alpha); // draw the floating label From c7a861eb5a1b52110461685a938ce6d9b9e7db29 Mon Sep 17 00:00:00 2001 From: bolein Date: Wed, 16 Mar 2016 14:41:44 +0200 Subject: [PATCH 3/3] treat default color value --- .../java/com/rengwuxian/materialedittext/MaterialEditText.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java index 83fe95fe..52f81dfd 100755 --- a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java +++ b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java @@ -1379,7 +1379,7 @@ protected void onDraw(@NonNull Canvas canvas) { int floatingLabelStartY = (int) (innerPaddingTop + floatingLabelTextSize + floatingLabelPadding - distance * (floatingLabelAlwaysShown ? 1 : floatingLabelFraction) + getScrollY()); // calculate the alpha - int alpha = ((int) ((floatingLabelAlwaysShown ? 1 : floatingLabelFraction) * (0.74f * floatingLabelFraction * (isEnabled() ? 1 : 0) + 0.26f) * Color.alpha(floatingLabelTextColor))); + int alpha = ((int) ((floatingLabelAlwaysShown ? 1 : floatingLabelFraction) * (0.74f * floatingLabelFraction * (isEnabled() ? 1 : 0) + 0.26f) * (floatingLabelTextColor != -1 ? 0xff : Color.alpha(floatingLabelTextColor)))); textPaint.setAlpha(alpha); // draw the floating label