Android密码可见性切换无法与支持库25一起使用? [英] Android password visibility toggle not working with support library 25?

查看:104
本文介绍了Android密码可见性切换无法与支持库25一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以通常的方式实现了带有密码字段的TextInputLayout:

I have implemented a TextInputLayout with a password field in the usual way:

<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <EditText
        android:id="@+id/returning_password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/prompt_password"
        android:inputType="textPassword"
        android:maxLines="1"
        android:textSize="14sp" />

</android.support.design.widget.TextInputLayout>

在使用Android支持库(最高版本为24.0.2,但切换到25.0.1之后)时,此方法工作正常:

This worked fine when using the Android support library up to version 24.0.2, but after switching to 25.0.1:

compile 'com.android.support:design:25.0.1'
compile 'com.android.support:support-v4:25.0.1'
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:support-vector-drawable:25.0.1'

我不再在小部件中看到密码可见性切换(也称为眼睛图标").更改为最新版本25.1.0不能解决此问题.

I no longer see the password visibility toggle (a.k.a. "eye icon") in the widget. Changing to the latest version 25.1.0 does not fix this problem.

我有什么需要与支持库25相结合更改的东西吗?或者这可能是Android的问题?

Is there anything that I missed and need to change in combination with the support library 25, or could this be an Android issue?

推荐答案

以这种方式尝试.

<android.support.design.widget.TextInputLayout
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   app:passwordToggleEnabled="true">

<EditText
    android:id="@+id/returning_password"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/prompt_password"
    android:inputType="textPassword"
    android:maxLines="1"
    android:textSize="14sp" />

</android.support.design.widget.TextInputLayout>

这可能对您有帮助!

现在默认情况下默认禁用TextInputLayout密码切换,以避免不必要地覆盖开发人员指定的最终可绘制对象.可以通过passwordToggleEnabled XML属性手动启用它.

The TextInputLayout password toggle is now disabled by default to avoid unnecessarily overwriting developer-specified end drawables. It may be manually enabled via the passwordToggleEnabled XML attribute.

最近的支持库修订

这篇关于Android密码可见性切换无法与支持库25一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆