Error in text showing ontop of suffix in TextInputLayout in andrfoid - android

i have a project, that i'm using
<com.google.android.material.textfield.TextInputLayout
i'm using it like that >
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
id="#+id/TextInputLayoutId
app:suffixText="suffeix_forText_input"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/TextInputEditTextId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/vitals_diastolic"
android:inputType="number"
android:maxLength="3"/>
</com.google.android.material.textfield.TextInputLayout>
but when i run into an error, the text and icon of the error are both on top of each other
i am using
the latest
api 'com.google.android.material:material:1.6.1'
it is a bonded view if it matters
do you know why this is happening that the text overlapping?
i am
this is the Error shown from the TextInputEditText

Related

Android TextInputEditText doesn't focus on cursor position

When trying to edit long text inside TextInputEditText, the focus goes always to the bottom, so the top (where actually the cursor is) stays out of the screen and you cannot see actually what you are typing. See a GIF showing the TextInputEditText problem that I describe.
My xml:
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.FilledBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Notes"
app:boxBackgroundColor="#android:color/transparent"
app:hintAnimationEnabled="false"
app:passwordToggleEnabled="false">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/notes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Notes"
android:imeOptions="flagNoExtractUi"
android:inputType="textMultiLine" />
</com.google.android.material.textfield.TextInputLayout>
Material library version:
implementation 'com.google.android.material:material:1.5.0'
The issue has been fixed with this commit so using the latest beta release seems to be working just fine:
implementation 'com.google.android.material:material:1.6.0-beta01'

endIconMode in TextInputLayout

I'm working with TextInputLayout and inside TextInputEditText.
I used app:endIconMode in TextInputLayout, then distance from hint and baseline are bigger than before, how to retrieve this distance?
This is my code:
<com.google.android.material.textfield.TextInputLayout
app:endIconMode="clear_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:hint="#string/hint_phon_number">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:inputType="phone"
android:maxLength="17"
android:textColor="#FF192331" />
</com.google.android.material.textfield.TextInputLayout>
This is because, I use this project material library, then this error appear, when I delete import this library, all were well

EditText with custom background turning red using TextInputLayout

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

I am using editText for password field in android. How to show the password visible for few seconds and then mask it with asterisk symbol?

The output should look like following image:
more simple way use TextInputLayout
compile design library to your dependecies
compile "com.android.support:design:26.0.+"
TextInputLayout
Layout which wraps an EditText (or descendant) to show a floating label when the hint is hidden due to the user inputting text.
<android.support.design.widget.TextInputLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="true">
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter EMail Address"
android:inputType="textPassword"/>
</android.support.design.widget.TextInputLayout>

Error Icon is not showing in all EditText fields

I am trying to show error icon in Edit Text and tried below code but it does not show error icon in all Edit Text Fields.
txtEmailAddess.requestFocus();
txtEmailAddess.setError(result.getEmailAddressMessage());
txtPassword.requestFocus();
txtPassword.setError(result.getPasswordMessage());
In the below screenshot, it shows error icon just in Password field. But not in Email Address field. Is that possible to show red circular icon in both fields?
Code in Xml
<android.support.design.widget.TextInputLayout
android:id="#+id/lblEmailAddress_login"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/txtEmailAddress"
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:id="#+id/lblPassword_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/lblEmailAddress_login">
<EditText
android:id="#+id/txtPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="45dp"
android:hint="#string/hint_password"
android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>
use a TextInputLayout
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.design.widget.TextInputLayout>
set the error using:
textInputLayout.setError("Error occurs");
use if else for setting error in text fields instead of requesting focus on every items of text fields
Refer these two answers (They will surely resolve your issue )
Errors with registration form Validation using setError() in Android
How to show all edittext error messages at once in android?

Categories

Resources