【问题标题】:app:passwordToggleEnabled="true" not working应用程序:passwordToggleEnabled="true" 不起作用
【发布时间】:2018-10-25 01:17:37
【问题描述】:

我正在尝试实现一个登录页面,这是我的密码字段TextInputLayout

<android.support.design.widget.TextInputLayout
        android:id="@+id/password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:hint="Password"
        app:passwordToggleDrawable="@drawable/eye_outline"
        android:theme="@style/GFSTextInputLayoutTheme"
        app:passwordToggleEnabled="true">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textPassword"
            android:textColor="@color/black"
            android:textColorHint="@color/light_grey"
            android:textSize="20dp" />

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

但不知何故,app:passwordToggleEnabled="true" 似乎不起作用。

这是我的 gradle 导入:

compile 'com.android.support:design:27.1.1'
compile 'com.android.support:support-v4:27.1.1'
compile 'com.android.support:appcompat-v7:27.1.1'
compile 'com.android.support:recyclerview-v7:27.1.1'
compile 'com.android.support:support-vector-drawable:27.1.1'
compile 'com.android.support.constraint:constraint-layout:1.1.0'
compile 'com.android.support:recyclerview-v7:27.1.1'
compile 'com.android.support:cardview-v7:27.1.1'

编辑:

styles.xml

<style name="GFSTextInputLayoutTheme" parent="TextAppearance.AppCompat">
    <!-- Hint color and label color in FALSE state -->
    <item name="android:textColorHint">@color/light_grey</item>
    <!-- Label color in TRUE state and bar color FALSE and TRUE State -->
    <item name="colorAccent">@color/light_grey</item>
    <item name="colorControlNormal">@color/light_grey</item>
    <item name="colorControlActivated">@color/gfs_blue</item>
</style>

知道为什么这不起作用吗?

【问题讨论】:

  • 在我的设备中找到相同的代码在工作中与问题分享您的@style/GFSTextInputLayoutTheme 主题
  • @NileshRathod 在帖子中添加了布局主题。

标签: java android passwords android-textinputlayout textinputlayout


【解决方案1】:

它一直在那里,但它是白色的,所以我看不到它。我只包含了这一行代码:

app:passwordToggleTint="@color/blue"

【讨论】:

    【解决方案2】:

    亲爱的@Dale Julian,无需输入 app:passwordToggleDrawable="@drawable/eye_outline"。 Android 会直接从 android 资源中获取。

    【讨论】:

    • 即使我删除它仍然不起作用。我只是尝试手动添加一个drawable,如果它可以工作的话。但不幸的是它没有。
    • 您的代码似乎是正确的,但我也尝试过,对我来说工作正常。请您删除 app:passwordToggleDrawable="@drawable/eye_outline" android:theme="@style/GFSTextInputLayoutTheme" 这几行代码后重试。
    • 还是不行。我会用一个新项目来试试这个。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-27
    • 2016-03-17
    • 2017-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多