问题描述
我正在尝试使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的可见性(可见,不可见或不可见)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!