Remove show password icon in Android N

后端 未结 3 2007
小鲜肉
小鲜肉 2020-12-29 03:06

New Android version automatically draws show password icon when I set android:inputType=\"textPassword\" in EditText view. How can I disable it? Thanks

相关标签:
3条回答
  • 2020-12-29 03:36

    The password icon (or eye-icon) use be removed with the method setPasswordVisibilityToggleEnabled or with app:passwordToggleEnabled through XML.

    For more information see support library revisions.

    Example:

    <android.support.design.widget.TextInputLayout
        android:id="@+id/new_password_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:errorEnabled="true"
        app:passwordToggleEnabled="false">
    
        <EditText
            android:id="@+id/password_edit"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/new_password"
            android:imeOptions="actionNext"
            android:inputType="textPassword"
            android:singleLine="true"/>
    
    </android.support.design.widget.TextInputLayout>
    
    0 讨论(0)
  • 2020-12-29 03:38

    compile 'com.android.support:appcompat-v7:24.2.0'

    compile 'com.android.support:design:24.2.0'

    in layout

            android:inputType="textPassword"
    

    Its Working

    0 讨论(0)
  • 2020-12-29 03:55
     <android.support.design.widget.TextInputLayout
        android:id="@+id/password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:passwordToggleEnabled="true"
        android:textColorHint="@color/colorhint"
        android:textColor="@color/colortext">
    

    true means you can show/hide password

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