inputType 不隐藏密码

inputType doesn't hide the password

我在 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"

你必须设置

android:password="true"

应该是textPassword看看this

<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" />

请试试这个

Edttext.setTransformationMethod(PasswordTransformationMethod.getInstance());

然后这个在你的布局中

android:password="true"