【发布时间】:2020-05-19 07:14:27
【问题描述】:
我正在使用密码切换来显示和隐藏密码。而且我不想使用自定义可绘制对象。但是,当此编辑文本生成错误时,它会覆盖切换密码图标并且无法向该图标添加填充或边距。如果有任何解决方案,那将是一种乐趣。 这是我正在使用的代码:
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textColorHint="@color/white"
app:passwordToggleEnabled="true"
app:passwordToggleTint="@color/white">
<EditText
android:id="@+id/et_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/white"
android:hint="@string/password"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:maxLength="40"
android:maxLines="1"
android:textColor="@color/white"
android:textColorHint="@color/app_green_color" />
</com.google.android.material.textfield.TextInputLayout>
【问题讨论】:
-
android:backgroundTint="@color/white" 删除此行
-
目前还不清楚您要达到的目标
-
@GabrieleMariotti 你可以在这个链接中看到图片i.stack.imgur.com/Vc21z.jpg我希望你能理解我的问题。
-
@SaadKhan 使用 1.1.0 或更高版本。错误图标出现,密码切换图标消失。
-
@GabrieleMariotti 谢谢,你拯救了我的一天。
标签: android android-textinputlayout material-components-android material-components android-textinputedittext