【问题标题】:I am using editText for password field in android. How to show the password visible for few seconds and then mask it with asterisk symbol?我在android中使用editText作为密码字段。如何显示密码可见几秒钟,然后用星号符号掩盖它?
【发布时间】:2018-03-09 20:08:36
【问题描述】:

输出应如下图所示:

【问题讨论】:

  • 显示您尝试过的内容。
  • 欢迎来到 StackOverflow!这个网站不是一个代码编写服务,你必须展示你尝试过的东西,解释它为什么不起作用,并提供重现问题的简单方法。请查阅“如何提出好问题”手册并通过添加相关信息来更新您的问题。 stackoverflow.com/help/how-to-ask
  • 发布您的代码。

标签: android android-edittext passwords


【解决方案1】:

更简单的使用方式TextInputLayout

将设计库编译到您的依赖项

compile "com.android.support:design:26.0.+"

TextInputLayout 当由于用户输入文本而隐藏提示时,包装 EditText(或后代)以显示浮动标签的布局。

<android.support.design.widget.TextInputLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:passwordToggleEnabled="true">

    <android.support.design.widget.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Enter EMail Address"
        android:inputType="textPassword"/>
</android.support.design.widget.TextInputLayout>

【讨论】:

    猜你喜欢
    • 2012-12-12
    • 1970-01-01
    • 2023-04-03
    • 2012-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多