Android中实现EditText密码显示隐藏的方法

作者:tianzhuo222 时间:2022-04-13 22:33:56 

在Google发布了support:design:23+以后我们发现有这么一个东西TextInputLayout,先看下效果图:

Android中实现EditText密码显示隐藏的方法


<android.support.design.widget.TextInputLayout
 android:id="@+id/pwdLayout"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 app:passwordToggleEnabled="true"
 >
 <EditText
 android:id="@+id/pwdEdt"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:hint="@string/edt_pwd_hint"
 android:maxLines="1"
 android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>

只要在布局中添加属性app:passwordToggleEnabled=”true”就可以实现当EditText的inputType=”textPassword”的时候在输入框的最右边就会显示眼睛一样的开关来显示和隐藏密码,需要的同学不妨试试看。

参考:

http://stackoverflow.com/questions/39019675/remove-show-password-icon-in-android-n

标签:android,edittext,密码
0
投稿

猜你喜欢

  • Spring Cloud gateway 网关如何拦截Post请求日志

    2022-06-19 03:19:46
  • Java List分页功能实现代码实例

    2022-06-02 13:56:14
  • 深入解析Java的Spring框架中的混合事务与bean的区分

    2021-12-28 19:48:41
  • 30条Java代码编写经验分享

    2022-01-09 06:41:42
  • C#实现Array添加扩展实例

    2023-02-16 23:01:03
  • Java实现简单登陆界面

    2022-11-25 05:47:47
  • 深入浅析Java Object Serialization与 Hadoop 序列化

    2023-07-30 17:02:16
  • mybatis @InsertProvider报错问题及解决

    2023-09-27 15:49:59
  • Java设计模式初识之备忘录模式详解

    2023-08-29 23:27:09
  • C#中异步和多线程的区别介绍

    2021-08-23 07:06:49
  • java连接MySQl数据库实例代码

    2021-12-18 18:19:36
  • Mybatis分页插件PageHelper的配置和简单使用方法(推荐)

    2022-03-20 06:34:55
  • android 6.0 写入SD卡的权限申请实例讲解

    2023-07-27 03:12:37
  • JAVA调用SAP WEBSERVICE服务实现流程图解

    2023-11-07 03:54:57
  • SpringBoot在Controller层接收参数的n种姿势(超详细)

    2023-01-28 00:54:39
  • java web中图片验证码功能的简单实现方法

    2023-06-07 13:30:53
  • 详解SpringBoot迭代发布JAR瘦身配置

    2021-11-14 19:10:48
  • java 高并发中volatile的实现原理

    2022-11-24 19:58:22
  • Flutter中嵌入Android 原生TextView实例教程

    2023-07-05 02:02:00
  • SpringBoot全局配置long转String丢失精度的问题解决

    2023-02-19 22:58:49
  • asp之家 软件编程 m.aspxhome.com