java textinputlayout密码切换图标被阻止
我不知道如何解释的话,但让所附的图片做说话的雅
基本上,setError图标阻止了密码切换图标
起初,我认为这是一个简单的布局问题,在这里,我一直在玩弄色彩&;然而,这么多的试用;但我似乎找不到解决问题的办法
我将在此处发布我的XML供您参考:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:app="http://schemas.安卓.com/apk/res-auto"
xmlns:tools="http://schemas.安卓.com/tools"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:background="@drawable/bokeh"
tools:context=".RegistrationActivity">
<LinearLayout
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:orientation="vertical">
<ImageView
安卓:layout_width="495dp"
安卓:layout_height="130dp"
安卓:layout_gravity="center_horizontal"
安卓:layout_marginTop="15dp"
安卓:src="@drawable/loginboa" />
<LinearLayout
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:layout_marginLeft="30dp"
安卓:layout_marginRight="30dp"
安卓:layout_marginTop="10dp"
安卓:orientation="vertical"
安卓:weightSum="1">
<EditText
安卓:id="@+id/etSignUpUsername"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:drawableLeft="@drawable/ic_user"
安卓:drawablePadding="20dp"
安卓:background="@drawable/edittext_bg"
安卓:hint="Name"
安卓:textColorHint="#a3a1a1"
安卓:inputType="textPersonName"
安卓:padding="10dp"
安卓:layout_weight="0.10"/>
<EditText
安卓:id="@+id/etSignUpEmail"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:layout_weight="0.10"
安卓:drawableLeft="@drawable/ic_email"
安卓:drawablePadding="20dp"
安卓:background="@drawable/edittext_bg"
安卓:layout_marginTop="3dp"
安卓:hint="Email"
安卓:inputType="textEmailAddress"
安卓:padding="10dp"
安卓:textColorHint="#a3a1a1" />
<安卓.support.design.widget.TextInputLayout
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:layout_marginTop="5dp"
app:passwordToggleEnabled="true"
app:hintEnabled="false">
<EditText
安卓:id="@+id/etSignUpPassword"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:hint="Password"
安卓:textColorHint="#a3a1a1"
安卓:inputType="textPassword"
安卓:drawableStart="@drawable/ic_password"
安卓:background="@drawable/edittext_bg"
安卓:layout_marginTop="3dp"
安卓:drawablePadding="20dp"
安卓:padding="10dp"
安卓:layout_weight="0.09"/>
</安卓.support.design.widget.TextInputLayout>
<TextView
安卓:id="@+id/tvPasswordHint"
安卓:visibility="gone"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:padding="5dp"
安卓:text="Password must contain at least 8 characters including
one uppercase letter, one lowercase letter, one number & one
special character."
安卓:textAlignment="center"
安卓:textSize="12sp"
安卓:textStyle="bold|italic"
安卓:textColor="#ff0000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.623" />
<EditText
安卓:id="@+id/etSignUpDepartment"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:layout_weight="0.09"
安卓:drawableLeft="@drawable/ic_department"
安卓:drawablePadding="20dp"
安卓:background="@drawable/edittext_bg"
安卓:layout_marginTop="3dp"
安卓:hint="Department"
安卓:inputType="text"
安卓:padding="10dp"
安卓:textColorHint="#a3a1a1" />
<EditText
安卓:id="@+id/etSignUpRole"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:layout_weight="0.09"
安卓:drawableLeft="@drawable/ic_role"
安卓:drawablePadding="20dp"
安卓:background="@drawable/edittext_bg"
安卓:layout_marginTop="3dp"
安卓:hint="Role"
安卓:inputType="text"
安卓:padding="10dp"
安卓:textColorHint="#a3a1a1" />
<Button
安卓:id="@+id/btnRegister"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:layout_marginTop="25dp"
安卓:background="@drawable/button_bg"
安卓:text="SIGN UP"
安卓:textSize="20dp"
安卓:textColor="#000000"/>
<TextView
安卓:id="@+id/tvUserLogin"
安卓:layout_width="match_parent"
安卓:layout_height="wrap_content"
安卓:layout_marginTop="8dp"
安卓:layout_marginRight="10dp"
安卓:layout_marginBottom="8dp"
安卓:text="Already have an account? LOGIN NOW! "
安卓:textColor="#ba080000"
安卓:textAlignment="center"
安卓:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.382"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvInfo"
app:layout_constraintVertical_bias="0.437" />
</LinearLayout>
</LinearLayout>
我本可以创建另一个可绘制的红色感叹号图标,但我喜欢错误消息弹出的方式
如果可能的话,我想保持这种方法,但当然有更好的布局安排。因此,有人知道我如何解决这个问题吗?多谢各位
# 1 楼答案
有个办法
# 2 楼答案
我不知道你是否已经解决了这个问题。 我的解决方案是将错误设置为TextLayout和TextLayout。erroricandrawable=null
# 3 楼答案
将id分配给textinputlayout,将错误设置为textinputlayout,而不是edittext。 比如:
课堂上:
不要忘记在条件匹配后设置错误(null)