Here is presented a part of layout I have in project, I use databinding.
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_goneMarginEnd="0dp"
<com.google.android.material.textfield.MaterialAutoCompleteTextView
android:id="@+id/et_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="text"
android:textCursorDrawable="@drawable/orange_cursor"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
Here is a part of code where I configure listed below views.
private void setupCrossEndIcon() {
binding.tilName.setEndIconMode(END_ICON_CUSTOM);
binding.tilName.setEndIconOnClickListener(v -> onCrossClicked());
binding.tilName.setEndIconVisible(true);
binding.tilName.setEndIconDrawable(R.drawable.ic_cross);
setEndIconColor();
}
private void onCrossClicked() {
binding.etName.setText("");
binding.tilName.setEndIconVisible(false);
}
the problem occurs when MaterialAutoCompleteTextView is filled with big multilined text and then onCrossClicked is called, because the height of MaterialAutoCompleteTextView stays big every time when binding.tilName.setEndIconVisible(false);
is called whenever it was called before or after binding.etName.setText("")
. In case when I remove binding.tilName.setEndIconVisible(false);
, size adjusts correctly.
I have tried to call binding.etName.invalidateLayout();
binding.etName.setMaxLines(1);
, also tried to use binding.tilBeneficiaryName.setEndIconDrawable(null);
.
Upgrading com.google.android.material:material
doesn't help, current version is 1.9.0
Nothing works for me. The height of Text Field stays big when I operate on endIcon as when it was filled with multilined text despite text is "". It should be related to some logic of endIcons.
In case someone face this issue, please help me to find solution.