android : TextInputLayout hides drawableRight of c

2019-04-22 21:00发布

问题:

I am always updated with library updates, and this is what it resulted into.

In build.gradle(Project:xxx):

classpath 'com.android.tools.build:gradle:2.2.0-beta1'

In build.gradle(Module:app)

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

And put password field as below:

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

    <android.support.v7.widget.AppCompatEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>

Taadaa...My Password field looks now as below:

You can also go simply with EditText.

But, there are some glitches in this update.

Problem: If I put any drawableRight in EditText, it displays nothing. TextInputLayout also has property to disable toggle functionality. I did it that too as below, but no success:

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

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:drawableRight="@drawable/ic_alarm_on_black_24dp"
        android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>

Can anyone help me please.

回答1:

I reported the issue at https://code.google.com/p/android/issues/detail?id=221002.

It was a bug in the library version 24.2.0 but it has been fixed in version 24.2.1. Simply update as below:

compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'


回答2:

You need to upgrade the support library to 24.2.1 (see https://code.google.com/p/android/issues/detail?id=221002).