Android numeric password field

后端 未结 8 1632
春和景丽
春和景丽 2020-12-05 00:15

I have an EditText field which needs to be a numeric password field. Everything works OK in portrait mode; not in landscape. When the user selects the EditText field, the UI

相关标签:
8条回答
  • 2020-12-05 00:24

    The simplest solution that I found for a numeric text entry that needed to be hidden (password style) was to use: android:inputType="numberPassword"

    Full example that worked for me:

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        style="@style/MyLargeTextBox"
        android:background="@android:drawable/editbox_background_normal"
        android:id="@+id/txtWebServicePIN"
        android:layout_row="3"
        android:layout_column="2"
        android:layout_columnSpan="2"
        android:minWidth="100dp"
        android:maxWidth="100dp"
        android:inputType="numberPassword"
        android:maxLength="6"/>
    
    0 讨论(0)
  • 2020-12-05 00:27

    Try this in XML & nothing changes in manifest file,

    <EditText
             android:id="@+id/etPassword"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:inputType="textPassword"
             android:singleLine="true" />
    
    0 讨论(0)
  • 2020-12-05 00:32

    To fix the issue where the password is visible in the landscape mode full-screen editor (as Marcus described), you can add the following line to disable the full-screen editor:

    editText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    

    You may also want to change the typeface to monospace to better emulate the text-password behavior:

    editText.setTypeface(Typeface.MONOSPACE);
    
    0 讨论(0)
  • 2020-12-05 00:34

    This how to make input password that has hint which not converted to * !!.

    On XML :

    android:inputType="textPassword"
    android:gravity="center"
    android:ellipsize="start"
    android:hint="Input Password !."
    

    thanks to : mango and rjrjr for the insight :D.

    0 讨论(0)
  • 2020-12-05 00:34

    Try with this:

    EditText input = (EditText) findViewById(R.id.input);
    input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
    

    More info HERE

    0 讨论(0)
  • 2020-12-05 00:37

    Using the deprecated

    android:password="true"
    

    may solve your problem.

    0 讨论(0)
提交回复
热议问题