Pratik Butani
Pratik Butani

Reputation: 62391

Android TextInputLayout Password toggle not visible in new support library

I have compiled with following design library and it is displaying password HIDE/SHOW button at the right of EditText

compile 'com.android.support:design:24.2.1'

<android.support.design.widget.TextInputLayout
    android:id="@+id/login_password_text_input_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/spacing_normal">

    <android.support.v7.widget.AppCompatEditText
        android:id="@+id/login_password_edit_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:drawablePadding="@dimen/spacing_micro"
        android:hint="@string/prompt_password"
        android:imeActionId="@+id/login"
        android:imeActionLabel="@string/action_sign_in_short"
        android:imeOptions="actionUnspecified"
        android:inputType="textPassword"
        android:maxLines="1"
        android:text="password" />

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

like:

enter image description here

after updating to

compile 'com.android.support:design:25.0.1'

Its not visible, Why? Is there any bug?

Please guide.

Upvotes: 12

Views: 21224

Answers (6)

Dino Sunny
Dino Sunny

Reputation: 1051

Add endIconMode to Custom for adding drawable end for a textinputlayout.

<com.google.android.material.textfield.TextInputLayout app:endIconMode="custom" app:endIconDrawable="@drawable/ic_tick_grey" .... </com.google.android.material.textfield.TextInputLayout>

Upvotes: 2

Keshav Gera
Keshav Gera

Reputation: 11244

Using This

app:passwordToggleEnabled="true"  in TextInputLayout

and change dependency

compile 'com.android.support:appcompat-v7:26.0.1'

Setting up Gradle for api 26 (Android)

  <android.support.design.widget.TextInputLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textInputLayout2"
                android:layout_marginLeft="@dimen/box_layout_margin_left"
                android:layout_marginRight="@dimen/box_layout_margin_right"
                android:padding="@dimen/text_input_padding"
                app:passwordToggleEnabled="true">

                <EditText
                    android:id="@+id/et_password"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:drawableLeft="@android:drawable/ic_lock_lock"
                    android:drawablePadding="10dp"
                    android:paddingLeft="35dp"
                    android:gravity="top"
                    android:hint="Password"
                    android:inputType="textPassword"
                    android:paddingRight="@dimen/edit_input_padding"
                    android:paddingTop="5dp"
                    android:singleLine="true">
                </EditText>

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

Upvotes: 1

Javier Vieira
Javier Vieira

Reputation: 2140

I smashed my head with this one for hours.

From the release notes: https://developer.android.com/topic/libraries/support-library/revisions.html#

Fixed issues: 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.

So to have it back, you have to:

 <android.support.design.widget.TextInputLayout
    ...
    ...
    app:passwordToggleEnabled="true">

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

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

Upvotes: 11

Sumit Bhatt
Sumit Bhatt

Reputation: 718

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.

see revision for 25.0.1

Note : Every developer must see the revision document.

Upvotes: 2

Ravi
Ravi

Reputation: 35539

It is disabled in 25.0.1. If you want it, you need to manually enable it

Check reference here

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.

Upvotes: 2

pRaNaY
pRaNaY

Reputation: 25312

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.

from https://developer.android.com/topic/libraries/support-library/revisions.html

Upvotes: 18

Related Questions