单击支持库25.1.0后,TextInputEditText上的密码切换按钮消失

时间:2017-01-02 21:56:31

标签: android android-support-library android-inputtype android-textinputedittext

我有一个TextInputEditTextTextInputLayout android:inputType="textPassword" app:passwordToggleEnabled="true"使用TextInputEditText来显示com.android.support:design:24.2.0中的密码切换按钮,如下一张图片所示:

password toggle button example
问题一旦按下密码切换按钮,它就会永远消失 它在<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> 版本中运行良好。

我错过了一些新的东西吗?这是一个错误吗?

一些gradle项目的设置:
minSdkVersion 17
targetSdkVersion 25
编译&#39; com.android.support:support-v4:25.1.0&#39;
编译&#39; com.android.support:appcompat-v7:25.1.0&#39;
编译&#39; com.android.support:cardview-v7:25.1.0&#39;
编译&#39; com.android.support:design:25.1.0&#39;

在2个不同的Android 6.0(Marshmallow)设备上运行。

XML:

app:passwordToggleDrawable

如果我在TextInputLayout中使用<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> 自定义绘图,则它不会消失。

相关风格:

print(df.head())
df['Date'] = pd.to_datetime(df['Date'])
df.index = df['Date']
del df['Date']
df.sort_index()
print(df.head())

2 个答案:

答案 0 :(得分:2)

按照依赖

更改gradle文件
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文件中,为密码字段中的切换按钮添加以下行

 <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>

答案 1 :(得分:1)

添加

<item name="passwordToggleDrawable">@drawable/design_password_eye</item>
<item name="passwordToggleTint">@color/design_tint_password_toggle</item>
<item name="passwordToggleContentDescription">@string/password_toggle_content_description</item>

在TextLabelGray样式上,它将再次显示切换按钮。