How To Change Visiblity (visible, Invisible Or Gone ) Of Setendicondrawable In Textinputlayout Android?
I am trying to make invisible or visibility gone of endIconDrawable which is the edit icon in the picture above for FirstName field only and want to keep visibile edit icon rest o
Solution 1:
If you want to do it in the layout (static way) just don't add the app:endIconDrawable
/app:endIconMode
attributes:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tilFirstName"
android:layout_width="match_parent"
android:layout_height="@dimen/_64dp">
Programmatically to remove the endIconDrawable
you can use:
textInputLayout.setEndIconMode(TextInputLayout.END_ICON_NONE);
To add the endIconDrawable
you can use:
textInputLayout.setEndIconMode(TextInputLayout.END_ICON_CUSTOM);
textInputLayout.setEndIconDrawable(R.drawable.xxxx);
Solution 2:
I tried @Gabriele Mariotti 's answer. It's good but it has a problem. I used the code for making endicon visible or invisible in text watcher and it didn't work as desired. Then I used isEndIconVisible attribute for textInputLayout and maje it true or false. It works correctly as desired.
Solution 3:
Add this android:visibility="gone"
Post a Comment for "How To Change Visiblity (visible, Invisible Or Gone ) Of Setendicondrawable In Textinputlayout Android?"