单击支持库25.1.0后,TextInputEditText上的密码切换按钮消失。 [英] Password toggle button on TextInputEditText disappears after click in Support Library 25.1.0
问题描述
我有一个 TextInputEditText
以及 TextInputLayout
和 android:inputType = textPassword
使用 app:passwordToggleEnabled = true
在 TextInputEditText
中显示密码切换按钮就像下一张图片一样:
问题是,一旦我按下密码切换按钮,
在 com.android.support:design:24.2.0
版本中运行良好。
I have a TextInputEditText
in conjunction with TextInputLayout
with android:inputType="textPassword"
using app:passwordToggleEnabled="true"
to show password toggle button in the TextInputEditText
like next image:
The problem is once I press the password toggle button, it disappears for ever.
It was working well in com.android.support:design:24.2.0
version.
我错过了一些新东西吗?是个错误吗?
一些gradle项目的设置:
minSdkVersion 17
targetSdkVersion 25
编译'com.android。 support:support-v4:25.1.0'
编译'com.android.support:appcompat-v7:25.1.0'
编译'com.android.support:cardview- v7:25.1.0'
编译'com.android.support:design:25.1.0'
在2个不同的Android 6.0中运行(棉花糖)
am I missing something new? it's a bug?
Some gradle project's setup:
minSdkVersion 17
targetSdkVersion 25
compile 'com.android.support:support-v4:25.1.0'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:cardview-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
Running in 2 different Android 6.0 (Marshmallow) devices.
XML:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/TextLabelGray"
app:passwordToggleEnabled="true">
<android.support.design.widget.TextInputEditText
android:id="@+id/profile_field_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/perfil_field_password"
android:inputType="textPassword"
android:maxLines="1"
android:maxLength="100"
android:imeOptions="actionNext"
android:imeActionLabel="@string/perfil_field_tipo_documento"
android:textColor="@color/colorAccent"
android:textSize="@dimen/perfil_text_view_text_size"
android:paddingStart="15dp"
android:paddingEnd="5dp"/>
</android.support.design.widget.TextInputLayout>
如果我将 app:passwordToggleDrawable
与 TextInputLayout
中的自定义可绘制对象不会消失。
If I use app:passwordToggleDrawable
with a custom drawable in TextInputLayout
it doesn't disappear.
相关样式:
<style name="TextLabelGray" parent="TextAppearance.AppCompat">
<!--//hint color And Label Color in False State-->
<item name="android:textColorHint">@color/gray_text_color</item>
<item name="android:textColorHighlight">@color/gray_text_color</item>
<item name="android:textColorLink">@color/gray_text_color</item>
<item name="colorAccent">@color/gray_text_color</item>
<item name="colorControlNormal">@color/gray_text_color</item>
<item name="colorControlActivated">@color/gray_text_color</item>
</style>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="colorControlNormal">@color/colorControlNormal</item>
<item name="searchViewStyle">@style/AppTheme.MySearchViewStyle</item>
</style>
推荐答案
通过遵循依赖性更改gradle文件
change gradle file by following dependency
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
在xml文件中,在密码字段中为切换按钮添加以下行
In xml file, add following lines for toggle button in password field
<android.support.design.widget.TextInputLayout
android:id="@+id/text_input_layout_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
app:passwordToggleEnabled="true">
<android.support.design.widget.TextInputEditText
android:id="@+id/text_input_edit_text_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Password"
android:imeActionId="@+id/login"
android:imeActionLabel="Login"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
tools:text="password" />
</android.support.design.widget.TextInputLayout>
这篇关于单击支持库25.1.0后,TextInputEditText上的密码切换按钮消失。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!