如标题所述,我的setError图标和endIconMode融合为一
基本上我希望 endIconMode 位于左侧或右侧一点。我该怎么做?
这是 Java:
private void userLogin() {
String password = passwordEditText.getText().toString().trim();
if (password.length() < 6) {
passwordEditText.setError("Erorr Message" );
passwordEditText.requestFocus();
return;
}
这是 xml:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textPasswordField"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginLeft="32dp"
android:layout_marginEnd="32dp"
android:layout_marginRight="32dp"
android:hint="Inserisci la Password!"
app:boxBackgroundMode="outline"
app:boxCornerRadiusBottomEnd="16dp"
app:boxCornerRadiusBottomStart="16dp"
app:boxCornerRadiusTopEnd="16dp"
app:boxCornerRadiusTopStart="16dp"
app:endIconMode="password_toggle"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.55"
app:startIconDrawable="@drawable/icons8_key_24">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/passwordEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>
最佳答案
一个快速解决方案是使用填充将错误消息移至左侧。
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/passwordEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingRight="40dp"
android:inputType="textPassword" />
看起来像这样。
关于java - EditText setError 图标和 endIconMode 融合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65344370/