I have a simple TextInputLayout:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tilPwd"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Passcode"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" >
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:singleLine="true" />
</com.google.android.material.textfield.TextInputLayout>
Then I have other views below.
The issue is that when I set the error on the TextInputLayout the height increases and pushes all the views below. I tried a workaround setting a blank helperText, but when in talkback the blank helperText will be read and that's not what I want.
Is there a clean solution other then wrapping the TextInputLayout in some ViewGroup with a set height?
After a day of tries, I actually found the solution:
public void setHelperTextEnabled (boolean enabled)
Whether the helper text functionality is enabled or not in this layout. Enabling this functionality before setting a helper message via setHelperText(CharSequence) will mean that this layout will not change size when a helper message is displayed.
Basically it occupies in advance the space of the helperText (even if it's not set), and that's the same space occupied from the error.
Worth to notice that the equivalent xml attribute "app:helperTextEnabled" does not solve the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With