textinputlayout 密码切换图标被阻止

2024-03-19

我不知道如何用文字解释,但让附图来说话吧?

基本上,setError 图标挡住了密码切换图标。

最初,我认为这是一个简单的布局问题,我尝试了颜色和背景等。但是,经过多次尝试和错误,我似乎找不到问题的解决方案。

我将在这里发布我的 XML 供您参考:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bokeh"
tools:context=".RegistrationActivity">


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ImageView
        android:layout_width="495dp"
        android:layout_height="130dp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="15dp"
        android:src="@drawable/loginboa" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="30dp"
    android:layout_marginRight="30dp"
    android:layout_marginTop="10dp"
    android:orientation="vertical"
    android:weightSum="1">

    <EditText
        android:id="@+id/etSignUpUsername"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:drawableLeft="@drawable/ic_user"
        android:drawablePadding="20dp"
        android:background="@drawable/edittext_bg"
        android:hint="Name"
        android:textColorHint="#a3a1a1"
        android:inputType="textPersonName"
        android:padding="10dp"
        android:layout_weight="0.10"/>

    <EditText
        android:id="@+id/etSignUpEmail"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.10"
        android:drawableLeft="@drawable/ic_email"
        android:drawablePadding="20dp"
        android:background="@drawable/edittext_bg"
        android:layout_marginTop="3dp"
        android:hint="Email"
        android:inputType="textEmailAddress"
        android:padding="10dp"
        android:textColorHint="#a3a1a1" />

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        app:passwordToggleEnabled="true"
        app:hintEnabled="false">

        <EditText
            android:id="@+id/etSignUpPassword"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Password"
            android:textColorHint="#a3a1a1"
            android:inputType="textPassword"
            android:drawableStart="@drawable/ic_password"
            android:background="@drawable/edittext_bg"
            android:layout_marginTop="3dp"
            android:drawablePadding="20dp"
            android:padding="10dp"
            android:layout_weight="0.09"/>

    </android.support.design.widget.TextInputLayout>


    <TextView
        android:id="@+id/tvPasswordHint"
        android:visibility="gone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="5dp"
        android:text="Password must contain at least 8 characters including 
        one uppercase letter, one lowercase letter, one number &amp; one 
        special character."
        android:textAlignment="center"
        android:textSize="12sp"
        android:textStyle="bold|italic"
        android: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
        android:id="@+id/etSignUpDepartment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.09"
        android:drawableLeft="@drawable/ic_department"
        android:drawablePadding="20dp"
        android:background="@drawable/edittext_bg"
        android:layout_marginTop="3dp"
        android:hint="Department"
        android:inputType="text"
        android:padding="10dp"
        android:textColorHint="#a3a1a1" />

    <EditText
        android:id="@+id/etSignUpRole"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.09"
        android:drawableLeft="@drawable/ic_role"
        android:drawablePadding="20dp"
        android:background="@drawable/edittext_bg"
        android:layout_marginTop="3dp"
        android:hint="Role"
        android:inputType="text"
        android:padding="10dp"
        android:textColorHint="#a3a1a1" />

    <Button
        android:id="@+id/btnRegister"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="25dp"
        android:background="@drawable/button_bg"
        android:text="SIGN UP"
        android:textSize="20dp"
        android:textColor="#000000"/>

    <TextView
        android:id="@+id/tvUserLogin"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:layout_marginRight="10dp"
        android:layout_marginBottom="8dp"
        android:text="Already have an account? LOGIN NOW! "
        android:textColor="#ba080000"
        android:textAlignment="center"
        android: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>

我本来可以创建另一个可绘制对象作为红色感叹号图标,但我喜欢错误消息的弹出方式。

如果可能的话,我想保留这种方法,但当然有更好的布局安排。因此,有人知道我该如何解决这个问题吗?谢谢。


将 id 分配给 textinputlayout 并将 setError 分配给 textinputlayout,而不是 edittext。 喜欢:

  <android.support.design.widget.TextInputLayout
    android:id="@+id/tilSignUpPassword"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="5dp"
    app:passwordToggleEnabled="true"
    app:hintEnabled="false">

    <EditText
        android:id="@+id/etSignUpPassword"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Password"
        android:textColorHint="#a3a1a1"
        android:inputType="textPassword"
        android:drawableStart="@drawable/ic_password"
        android:background="@drawable/edittext_bg"
        android:layout_marginTop="3dp"
        android:drawablePadding="20dp"
        android:padding="10dp"
        android:layout_weight="0.09"/>

 </android.support.design.widget.TextInputLayout>

在班上:

 //your condition
  .....
  tilSignUpPassword.setError("Message")
  .....

不要忘记在条件匹配后 setError(null) 。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

textinputlayout 密码切换图标被阻止 的相关文章

随机推荐

  • 无法将 cuda:0 设备类型张量转换为 numpy。首先使用 Tensor.cpu() 将张量复制到主机内存

    我试图展示 GAN 网络在某些指定时期的结果 打印当前结果的功能之前是在 TF 中使用的 我需要换成pytorch def show result G net z num epoch show False save False path r
  • 从 jar-with-dependencies 构建的 jar 中排除文件

    My pom xml包含以下内容来创建具有所有依赖项的项目的 jar 现在我有一个属性文件src main resources这是运行应用程序所必需的 我想从 IDE 开始使用它 但我不想将其发送到创建的 jar 文件中 因为设置是单独维护
  • Prolog 中的分配性检查

    假设我有一个等价关系eq 以及多个二元运算符o 1 o 2 o n 我想找出哪些操作分配给其他操作 假设我有一个可以确定两个表达式是否等价的知识库 一个简单的解决方案是输入所有可能的查询 对于左分配性 eq o 1 Z o 1 X Y o
  • 实现一个类似于 Qt 的高性能互斥体

    我有一个多线程科学应用程序 其中多个计算线程 每个核心一个 必须将其结果存储在公共缓冲区中 这就需要互斥机制 工作线程只花费一小部分时间写入缓冲区 因此互斥锁在大多数时间都处于解锁状态 并且锁定很有可能立即成功 而无需等待另一个线程解锁 目
  • SqLite 多核处理

    如何配置 SqLite 3 使用 1 个以上的 CPU 核心来处理单个查询 从3 8 7版本开始 SQLite可以使用多线程对大数据集进行并行排序
  • file_put_contents(C:\xampp\htdocs\instant\storage\framework/sessions/FF): 无法打开流: 没有这样的文件或目录

    我尝试在 Amazon elasticBeanstalk 上上传此实例 但似乎不起作用 我尝试使用 ssh 访问文件但无济于事 i did php artisan config cache and composer dump autoloa
  • 如何动态禁用按钮

    我想动态地使按钮变灰 怎么做 in xaml
  • DTMobileIS 的含义是什么?

    当我使用Instruments工具来监视我的内存使用情况 我发现一个名为DTMobileIS使用了大约 40 的实际内存 然后我的应用程序没有足够的内存 所以它崩溃了 我对此很好奇DTMobileIS意味着 有人知道吗 Edit 这好像是D
  • JavaFX 模块化应用程序,java.lang.module.FindException:未找到模块 javafx.controls(Java 11、Intellij)

    我的模块化 JavaFX 应用程序有问题 我创建了一个 JavaFX 项目并添加了 JavaFX 库 并且 JavaFX 模块得到了识别 但是 我不断收到这些错误消息 Error occurred during initialization
  • UIMA Ruta 使用由某些文本分隔的功能创建注释

    我有一些带有注释的文本 如下所示 wewf werwfwef wewfwefwwew wefewefwff AnnotationA asdfawece aefae eafewfaefa aefafe ceaewfae adfcaecae a
  • Google Chrome 开发工具无法在 Elements Tag 中显示正文内容

    大家都有这样的情况吗 Chrome开发工具Elements标签下 body标签的内容无法显示 唯一的方法是关闭开发工具并重新打开 这是一个 Chrome 错误 在 Canary 中仍然发生 crbug com 829884 https bu
  • ggplot geom_bar 的比例[重复]

    这个问题在这里已经有答案了 使用 ggplot 最简单的方法是什么 与此处相同 我需要调用 prop table 还是有更简单的方法 可重现的示例 x lt c good good bad bad bad bad perfect perfe
  • 无法定位到动态链接库

    我在读取 C 中的文本文件时遇到问题 所以基本上我想使用此代码读取 cmd 上的文本文件 但是会弹出错误 include
  • 如何从内容页使用母版页中的方法

    我正在使用 C 编写 ASP NET 4 应用程序 我有一个母版页 其中有以下方法 public void DisplayMessage string input Label myMessageDisplayer Label FindCon
  • 更改 x 轴上的刻度

    我正在尝试找出 d3 js 定义轴时 如何在 x 轴上获得自定义标签 例如 我得到的默认标签是 20 30 40 50 60 70 80 然而 我想要这样的东西 20 26 32 38 44 50 56 我目前正在学习它并根据官方提供的示例
  • 用线性渐变制作CSS3三角形

    我需要创建一侧带有三角形的按钮 像这样http css tricks com triangle breadcrumbs 具有线性垂直渐变和边框 我想使用纯CSS3 如果我需要45度的 三角形 就可以了 我就这样写 button after
  • 使用循环在rmarkdown中生成一段文本

    我需要生成一份由多个部分组成的报告 所有部分看起来都很相似 只有一些数据差异 部分的数量也取决于数据 我最终想要拥有的是这样的 r section names c A B C section data c 13 14 16 some loo
  • 使用C#登录https站点

    我正在尝试编写一个小程序 用于登录 Verizon 网站 然后检查该月还剩多少分钟 我需要帮助了解如何使用 C 登录该网站 我知道我需要使用 webrequest 来发布登录信息 但我不知道如何去做 带有登录表单的网站是https logi
  • Django 使用整数参数(主键)从模板构建 URL

    我在模板中有这个链接 a href Item 1 a 以及 urls py 中的这个 url url r item P
  • textinputlayout 密码切换图标被阻止

    我不知道如何用文字解释 但让附图来说话吧 基本上 setError 图标挡住了密码切换图标 最初 我认为这是一个简单的布局问题 我尝试了颜色和背景等 但是 经过多次尝试和错误 我似乎找不到问题的解决方案 我将在这里发布我的 XML 供您参考