如何在TextInputLayout android中更改setEndIconDrawable的可见性(可见,不可见或不可见)? [英] how to change visiblity (visible, invisible or gone ) of setEndIconDrawable in TextInputLayout android?

查看:572
本文介绍了如何在TextInputLayout android中更改setEndIconDrawable的可见性(可见,不可见或不可见)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使endIconDrawable的不可见性或可见性消失,endIconDrawable仅是上图中的FirstName字段中的编辑图标,并且想保留其余字段的可见编辑图标,但无法执行?我该怎么办?

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 of the fields but unable to do? How can i do this?

      <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/tilFirstName"
                android:layout_width="match_parent"
                android:layout_height="@dimen/_64dp"
                app:endIconDrawable="@drawable/icon_edit"
                app:endIconMode="custom">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/etFirstName"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:focusableInTouchMode="false"
                    android:hint="@string/label_fname"
                    android:inputType="textCapWords" />
            </com.google.android.material.textfield.TextInputLayout>

我希望获得如下图所示的内容:

I wanted to get the following as shown in the below image:

推荐答案

如果要以布局方式(静态方式)进行操作,只需不添加app:endIconDrawable/app:endIconMode属性:

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

以编程方式删除您可以使用的endIconDrawable:

Programmatically to remove the endIconDrawable you can use:

textInputLayout.setEndIconMode(TextInputLayout.END_ICON_NONE);

要添加endIconDrawable,您可以使用:

textInputLayout.setEndIconMode(TextInputLayout.END_ICON_CUSTOM);
textInputLayout.setEndIconDrawable(R.drawable.xxxx);

这篇关于如何在TextInputLayout android中更改setEndIconDrawable的可见性(可见,不可见或不可见)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆