EditText with custom background turning red using TextInputLayout - android

I'm using an EditText with a drawable as background and a TextInputLayout
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:errorEnabled="true"
app:hintEnabled="false">
<EditText
android:id="#+id/input_edittext"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="#drawable/input_border"
android:textColor="#color/black"
android:textColorHint="#color/gray" />
</android.support.design.widget.TextInputLayout>
Every time there an error it looks like the error was clear
But when I touch the EditText (doesn't change the focus of the editText) again all the EditText becomes red
For setting the error and clear in the TextInputLayout I'm using
input_layout.setError(getResources().getString(id));
input_edittext.getBackground().clearColorFilter();
Do you have any idea how to solve it? When we don't use the background, it doesn't happen

Related

Android EditText with animated hint?

How can I create an Android EditText with a hint like this (with animation)?
So when I tap inside the EditText, the hint shrinks and goes on top of the input text, like in this example:
Use the code given below for all purposes:
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/textField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/label">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
For Password filed with toggle eye use this:
<com.google.android.material.textfield.TextInputLayout
...
app:endIconMode="password_toggle">
<com.google.android.material.textfield.TextInputEditText
...
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>
Learn more from here: https://material.io/components/text-fields/android

How to make Textinputlayout hint multi-line?

I want to make Textinputlayout hint multiline with material outlinedbox even hint in floating mode. I have searched a lot but didn't found any solution can anyone help me how to achieve this task?
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/tilFieldLabel"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:hintTextAppearance="#style/AddApplicationTextLabel">
<utilities.customcontrols.BodyEditText
android:id="#+id/etValue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoLink="web"
android:gravity="start"
android:inputType="textMultiLine"
android:maxLength="1000"
android:textColor="#color/black"
android:textSize="#dimen/_13ssp"
android:theme="#style/AddApplicationEditTextField"
custom:customfont="bold" />
</com.google.android.material.textfield.TextInputLayout>
TLDR:
Set app:hintEnabled="false" for TextInputLayout
Description:
If you leave hintEnabled to true (true by default) the hint will be single line and turns into a label when the user taps the EditText giving it focus.
If you change hintEnabled to false this feature is removed and the EditText shows the hint with multiple lines as intended. It does not turn into a label and disappears once the user starts actually typing.
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:hintEnabled="false"
app:boxBackgroundMode="none">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Your long hint"/>
</com.google.android.material.textfield.TextInputLayout>
Source: https://stackoverflow.com/a/67744575/13545849

TextinputLayout does not display the style correctly if hintEnabled false

I have TIL for entering phone number. The input should be frame so set style. But I need to disable hint animation, I set app:hintEnabled="false" animation work correct, but my border not displayed correctly. Please help
View:
View on focus:
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/phone_text_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
app:hintEnabled="false"
app:hintAnimationEnabled="false"
>
<com.bitnic.loyalitybitnic.widget.FTextInputEditText
android:id="#+id/phone_edit_text_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:hint="#string/phone"
app:style_font="medium"
/>
</com.google.android.material.textfield.TextInputLayout>
Update:
If I delete app:hintEnabled="false" then the view displayed correct
Correct view

Material Design Input Text

Is there a way to create an input field that looks like the ones on this image - Icon on the left, input on the right - using only the default TextInputLayout?
I've tried several combinations, and the icon always stays inside the TextInputEditText. I've tried changing the TextInputLayout orientation to horizontal but it didn't work as well. Is there anyway of doing this without placing an ImageView and an EditText inside of another ViewGroup?
Below is the code I used to create an input field, but with the icon remains inside the TextInputEditText.
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Test"
>
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="#drawable/ic_bank_card_back_grey_24dp"
android:drawablePadding="#dimen/default_padding"
/>
</android.support.design.widget.TextInputLayout>
Does this fit the bill ? :
<android.support.design.widget.TextInputLayout
android:id="#+id/TextInputLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<android.support.v7.widget.AppCompatEditText
android:id="#+id/EditText1"
android:hint="code"
android:text="0044"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="phone"
android:minWidth="350dp"
android:drawableLeft="#drawable/cross"
android:drawableStart="#drawable/cross"
android:textColor="#00ff00"
android:textColorHint="#ff0000"
android:textCursorDrawable="#null"
/>
</android.support.design.widget.TextInputLayout>
image from code:

Double exclamation mark on EditText setError when used on a password type field

In my application I use the Design Support Library's TextInputLayout around all my EditTexts that require the hint to label effect. However I noticed an adverse effect of doing so - applying it to a password field will make the setError method apply two exclamation marks: one in the middle of the EditText and one at the proper place, slightly covering the "eye" (password visibility) icon.
This only happens on fields that have the inputType set to textPassword.
How could I fix this?
EDIT:
XML layout
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/loginEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_email"
android:inputType="textEmailAddress"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/loginPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_password"
android:inputType="textPassword"/>
</android.support.design.widget.TextInputLayout>
try to set your error message just for TextInputLayout and remove it from editText object.

Categories

Resources