1

Hello I am trying to set hint text of EditText to password chars but currently when I start to type then chars appear like password chars but hint text appear as simple text form so Is it possible to make hint text of password field to password character instead of simple plain text.

See in the below screenshot it is displaying "Password" in simple text format and I want this should show password chars.

I tried this thread solution Android EditText for password with android:hint but did not work for me

<EditText
    android:id="@+id/passwordEditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/sign_up_views_vertical_top_margin"
    android:background="@drawable/edittext_border"
    android:drawableLeft="@drawable/password_drawable"
    android:drawablePadding="10dp"
    android:hint="@string/sign_up_password"
    android:ellipsize="start"
    android:imeOptions="actionNext"
    android:inputType="textPassword"
    android:singleLine="true"
    android:textColorHint="@android:color/black" />

enter image description here

Community
  • 1
  • 1
N Sharma
  • 33,489
  • 95
  • 256
  • 444

3 Answers3

2

If you want to mask the hint text, better to change hint text sign_up_password to ******** in strings.xml.

That will show password masking text instead of "Password"

And changing hint text doesn't make a difference because user won't be able to read text, anyway.

MysticMagicϡ
  • 28,593
  • 16
  • 73
  • 124
1

Yes Thank guys, your comments are useful always :)

It worked for me by doing simply

<EditText
    android:id="@+id/passwordEditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/sign_up_views_vertical_top_margin"
    android:background="@drawable/edittext_border"
    android:drawableLeft="@drawable/password_drawable"
    android:drawablePadding="10dp"
    android:hint="@string/sign_up_password"
    android:imeOptions="actionNext"
    android:inputType="textPassword"
    android:singleLine="true"
    android:textColorHint="@android:color/black" />

strings.xml

<string name="sign_up_password">&#9679;&#9679;&#9679;&#9679;&#9679;&#9679;&#9679;&#9679;</string>
N Sharma
  • 33,489
  • 95
  • 256
  • 444
0

Just your EditText hint as ************* simply and it will show as you want.

 android:hint="*************"
GrIsHu
  • 29,068
  • 10
  • 64
  • 102