Skip to content Skip to sidebar Skip to footer

How To Not Change The Color Of The Label While Setting Error To Particular Textinputlayout Having Edittext Inside It?

I am using a Textinputlayout and edittext inside it, problem is when I set the error to the textinputlayout at the time of validations , it changes the color of my hint label also

Solution 1:

You need to override text input layout default style, with your customstyle.

styles.xml

<resources><stylename="TextLabel"><itemname="android:textColorHint">@color/colorPrimary</item><!-- Your Hint Color --><itemname="android:textSize">18sp</item><itemname="colorAccent">@color/colorPrimary</item><itemname="colorControlNormal">@color/colorPrimary</item><itemname="colorControlActivated">@color/colorPrimary</item></style><stylename="error_appearance"parent="@android:style/TextAppearance"><itemname="android:textColor">@color/colorAccent</item></style></resources>

activity_layout.xml

        <android.support.design.widget.TextInputLayout
            android:id="@+id/input_layout_mobile"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:theme="@style/TextLabel"
            app:errorTextAppearance="@style/error_appearance">

            <EditText
                android:id="@+id/edt_mobile"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:drawableLeft="@drawable/ic_phone_iphone_black_24dp"
                android:drawablePadding="8dp"
                android:drawableTint="@color/colorPrimary"
                android:hint="@string/email"
                android:inputType="number"
                android:textColor="#000" />
        </android.support.design.widget.TextInputLayout>

Focused:

Focused

Without focus:

Without focus

Error message:

enter image description here

Post a Comment for "How To Not Change The Color Of The Label While Setting Error To Particular Textinputlayout Having Edittext Inside It?"