diff --git a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java
index 77a84646..d4665444 100755
--- a/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java
+++ b/library/src/main/java/com/rengwuxian/materialedittext/MaterialEditText.java
@@ -148,6 +148,11 @@ public class MaterialEditText extends AppCompatEditText {
*/
private int errorColor;
+ /**
+ * the color for the disabled dotted underline.
+ */
+ private int disabledUnderlineColor;
+
/**
* min characters count limit. 0 means no limit. default is 0. NOTE: the character counter will increase the View's height.
*/
@@ -304,6 +309,7 @@ public class MaterialEditText extends AppCompatEditText {
private ColorStateList textColorStateList;
private ColorStateList textColorHintStateList;
private ArgbEvaluator focusEvaluator = new ArgbEvaluator();
+ private boolean dottedBottomLinesForDisabledState;
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
StaticLayout textLayout;
@@ -378,8 +384,10 @@ private void init(Context context, AttributeSet attrs) {
primaryColor = typedArray.getColor(R.styleable.MaterialEditText_met_primaryColor, defaultPrimaryColor);
setFloatingLabelInternal(typedArray.getInt(R.styleable.MaterialEditText_met_floatingLabel, 0));
errorColor = typedArray.getColor(R.styleable.MaterialEditText_met_errorColor, Color.parseColor("#e7492E"));
+ disabledUnderlineColor = typedArray.getColor(R.styleable.MaterialEditText_met_disabledBottomLineColor, -1);
minCharacters = typedArray.getInt(R.styleable.MaterialEditText_met_minCharacters, 0);
maxCharacters = typedArray.getInt(R.styleable.MaterialEditText_met_maxCharacters, 0);
+ dottedBottomLinesForDisabledState = typedArray.getBoolean(R.styleable.MaterialEditText_met_disabledBottomLineDotted, true);
singleLineEllipsis = typedArray.getBoolean(R.styleable.MaterialEditText_met_singleLineEllipsis, false);
helperText = typedArray.getString(R.styleable.MaterialEditText_met_helperText);
helperTextColor = typedArray.getColor(R.styleable.MaterialEditText_met_helperTextColor, -1);
@@ -1316,11 +1324,21 @@ protected void onDraw(@NonNull Canvas canvas) {
paint.setColor(errorColor);
canvas.drawRect(startX, lineStartY, endX, lineStartY + getPixel(2), paint);
} else if (!isEnabled()) { // disabled
- paint.setColor(underlineColor != -1 ? underlineColor : baseColor & 0x00ffffff | 0x44000000);
- float interval = getPixel(1);
- for (float xOffset = 0; xOffset < getWidth(); xOffset += interval * 3) {
- canvas.drawRect(startX + xOffset, lineStartY, startX + xOffset + interval, lineStartY + getPixel(1), paint);
+ int disabledLineColor = disabledUnderlineColor;
+ if (disabledUnderlineColor == -1){
+ disabledLineColor = underlineColor != -1 ? underlineColor : baseColor;
}
+ paint.setColor(disabledLineColor & 0x00ffffff | 0x44000000);
+ if (dottedBottomLinesForDisabledState){
+ float interval = getPixel(1);
+ for (float xOffset = 0; xOffset < getWidth(); xOffset += interval * 3) {
+ canvas.drawRect(startX + xOffset, lineStartY, startX + xOffset + interval, lineStartY + getPixel(1), paint);
+ }
+ }
+ else{
+ canvas.drawRect(startX, lineStartY, endX, lineStartY + getPixel(1), paint);
+ }
+
} else if (hasFocus()) { // focused
paint.setColor(primaryColor);
canvas.drawRect(startX, lineStartY, endX, lineStartY + getPixel(2), paint);
diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml
index ce50f9a2..196e0b41 100644
--- a/library/src/main/res/values/attrs.xml
+++ b/library/src/main/res/values/attrs.xml
@@ -17,6 +17,10 @@
+
+
+
+
diff --git a/sample/src/main/java/com/rengwuxian/materialedittext/sample/MainActivity.java b/sample/src/main/java/com/rengwuxian/materialedittext/sample/MainActivity.java
index 693d8e3f..66cf4174 100644
--- a/sample/src/main/java/com/rengwuxian/materialedittext/sample/MainActivity.java
+++ b/sample/src/main/java/com/rengwuxian/materialedittext/sample/MainActivity.java
@@ -24,6 +24,8 @@ protected void onCreate(Bundle savedInstanceState) {
initSingleLineEllipsisEt();
initSetErrorEt();
initValidationEt();
+
+ findViewById(R.id.disabledSolidLine).setEnabled(false);
}
private void initEnableBt() {
diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml
index 4c45dc19..1cbfc7f5 100644
--- a/sample/src/main/res/layout/activity_main.xml
+++ b/sample/src/main/res/layout/activity_main.xml
@@ -429,6 +429,15 @@
app:met_iconPadding="0dp"
app:met_maxCharacters="5" />
+
+
\ No newline at end of file