You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android中TextInputEditText设置textPassword后无法显示密码圆点求助

TextInputEditText设置textPassword不显示密码圆点的解决办法

嘿,我之前也遇到过一模一样的问题,给你几个靠谱的排查和解决方向:

首先,先检查你的布局代码里有没有冲突属性——如果你的TextInputEditText同时设置了android:password="true"和android:inputType="textPassword",这俩属性会互相干扰!旧的android:password早就被弃用了,直接删掉它就行。

然后,确认你的inputType设置绝对正确,别不小心写成textVisiblePassword(那是强制显示明文的),一定要是textPassword。

如果你是把TextInputEditText放在TextInputLayout里使用(这也是Material Design推荐的用法),确保你的布局结构是正确的,比如这样:

<com.google.android.material.textfield.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    <!-- 这个密码可见切换按钮是可选的,不影响圆点显示 -->
    app:passwordToggleEnabled="true">

    <TextInputEditText
        android:id="@+id/password_edit"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入密码"
        android:inputType="textPassword" />

</com.google.android.material.textfield.TextInputLayout>

如果布局没问题,就去检查Activity里的代码,有没有动态修改过这个输入框的inputType?比如不小心写了这样的代码:

passwordEdit.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);

要是有这种情况,赶紧改成正确的设置:

passwordEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);

还有一种可能是主题的问题——如果你的应用主题修改了EditText的默认样式,可能会导致密码圆点不显示。你可以给TextInputEditText单独指定密码样式的主题试试:

android:theme="@style/Widget.MaterialComponents.TextInputEditText.Password"

按这几步排查下来,应该就能解决密码不显示圆点的问题啦!

内容的提问来源于stack exchange,提问作者Junburg

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:35:18