当前位置: 代码迷 >> Android >> inputType 不会隐藏密码
  详细解决方案

inputType 不会隐藏密码

热度:68   发布时间:2023-08-04 11:53:22.0

我在EditText设置了属性android:inputType

android:inputType="textWebPassword"` 

但它仍然显示我输入的密码。 还有什么(或代替)应该做的吗?

 android:layout_width="match_parent"
 android:layout_height="@dimen/button_height"
 android:background="@drawable/background_edit"
 android:ems="10"
 android:gravity="center"
 android:hint="@string/new_pass_hint"
 android:inputType="textWebPassword"
 android:textColor="@color/edit_text_text_color"
 android:textColorHint="@color/edt_text_hint_color"
 android:textSize="@dimen/button_text_size"

请试试这个

Edttext.setTransformationMethod(PasswordTransformationMethod.getInstance());

那么这在你的布局中

android:password="true"

你必须设置

android:password="true"

应该是textPassword看看

<EditText
 android:id="@+id/edtPassword"
 android:layout_width="fill_parent"
 android:layout_height="42dp"
 android:layout_marginTop="16dp"
 android:hint="Password"
 android:inputType="textPassword"
 android:padding="5dip"
 android:singleLine="true"
 android:textColor="#363435"
 android:textSize="14sp" />