我有一个带有clear text endIcon
的TextInputLayout,但仅当TextInput具有焦点时(显示键盘时,该字符才可见。)>
只要字段中有输入,我希望明文图标始终可见。是否可以实现此行为?
这是我的xml:
<com.google.android.material.textfield.TextInputLayout style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:background="@drawable/search_view_background" app:endIconDrawable="@drawable/ic_close_black_24dp" app:endIconCheckable="true" app:endIconMode="clear_text" app:hintEnabled="false" app:startIconDrawable="@drawable/ic_search"> <com.google.android.material.textfield.TextInputEditText android:id="@+id/search_edit_text" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/empty" android:hint="@string/hint_socials_search" android:inputType="text" android:singleLine="true" android:textColor="?attr/colorOnSurface" /> </com.google.android.material.textfield.TextInputLayout>
感谢您的时间!
我有一个带有清晰文本endIcon的TextInputLayout,但是只有在TextInput具有焦点时(显示键盘时),它才可见。我希望明文图标始终显示为...
隐藏端图标是clear_text
模式的默认行为,您无法覆盖它。我认为实现所需行为的最简单方法是: