【问题标题】:Edittext with inputType="textPassword" has suddenly changed to making passwords Visible instead of being *****带有 inputType="textPassword" 的 Edittext 突然更改为使密码可见而不是 *****
【发布时间】:2015-12-20 15:13:18
【问题描述】:

奇怪的问题刚刚开始发生在我身上,我已经好几个月没有碰过那个文件了。

过去两天左右,我一直在研究新版本的 Android (6.0) API 23。今天我注意到在尝试登录我的应用程序时,密码字段完全可见。我一直在研究运行时权限,删除我认为不需要的权限并添加代码以在运行时请求权限。 Activity 这个EditText 字段在里面,几个月没碰过。然而不知何故,当我在里面打字时,我可以看到所有的字符。这是 EditText 只是为了确保我没有遗漏任何明显的东西:

<EditText
    android:id="@+id/password"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    android:hint="@string/password"
    android:textColorHint="@color/light_grey"
    android:imeOptions="actionDone"
    android:inputType="textPassword"
    android:paddingBottom="20dp"
    android:paddingLeft="20dp"
    android:paddingTop="20dp"
    android:layout_marginLeft="15dp"
    android:layout_marginRight="15dp"        
    android:textColor="@color/text_gray"/>

该应用现在指向 API 23、buildTools 23.0.1 以及更新到 v23.0.1 的所有支持库。我在两部手机上测试了我的应用程序,一部是 Lollipop 5.1.1,另一部是 6.0 M Preview 3。两者都有一个可见的密码。事实上,我的应用程序中有两个 Activites 有一个密码字段,当你注册时,当你登录时,两者都有 textPassword 作为inputType,但所有字符在两者中都是可见的。

我检查了 M 预览问题跟踪器,但没有找到任何东西,所以我转向这里。

让我们相信这与 Android 6.0 相关的一件事是,我刚刚从 Google Play 商店下载了我们的实时应用程序,它指向 API 22,EditText 字段工作正常。

发生了一些非常奇怪的事情,我无法弄清楚。非常感谢您的意见,在此先感谢您提供的任何 cmets。

编辑: 发现在我的 styles.xml 中将 textAllCaps 设置为 false 会导致此问题,不知道为什么。与 AppCompat 的 v23.0.1 有什么关系?

【问题讨论】:

  • 安全下有一个用户设置,强制所有密码都可见。是否可以在运行 M Preview 的手机上启用此功能?在设置包含密码字段的视图时,我在代码中以编程方式将此设置更改为关闭,但在 Android M 中,您现在必须请求权限。WRITE_SETTINGS 才能做到这一点。

标签: android android-edittext passwords android-6.0-marshmallow


【解决方案1】:

原来这只是一个奇怪的故障。我从我的 styles.xml 中删除了以下内容,它可以工作,然后将其添加回来并继续工作。不知道那是关于什么的。

<item name"textAllCaps>false</item>

【讨论】:

    猜你喜欢
    • 2011-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-11
    • 1970-01-01
    相关资源
    最近更新 更多