I have a layout file with a TextInputLayout:
<android.support.design.widget.TextInputLayout
android:id="@+id/fullname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:errorEnabled="true"
app:errorTextAppearance="@style/Error">
<EditText
android:id="@+id/fullnameEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Full Name"
android:inputType="textEmailAddress"
android:padding="26dp"/>
</android.support.design.widget.TextInputLayout>
When I call the setError() method on the TextInputLayout the hint goes to the top as if the TextInputLayout would have focus.
I would like to leave the hint untouched while setting the error. It should look something like this:
Any ideas how to build this layout?
you can do it with alternative way , you can call setError()
on OnCreate()
mTextInputLayout = findViewById(R.id.fullname);
mTextInputLayout.setError("Enter Your Full Name");
and when you want to show the Error do this
mTextInputLayout.setErrorEnabled(true);
and this will fix your problem with the hint
if (mTextInputLayout.isErrorEnabled()){
mTextInputLayout.setHintEnabled(false);
}else {
mTextInputLayout.setHintEnabled(true);
}