android - 浮动标签 TextInputLayout insideTextInputEdittext 添加清除图标右侧角与 onclick 功能
问题描述
我正在尝试在编辑文本框右侧角添加清除图标,并能够使用 Android 中的文本观察器功能清除键入的文本。
同时,我正在尝试在里面使用 Floating label edittext。但是,我无法在TextInputEditText
.
注意:我尝试过onDrawableRight
使用方法添加图像onTouchListener
,有些情况对我来说不适用。
解决方案
只需将TextInputLayout
与预打包 app:endIconMode="clear_text"
属性一起使用。
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/custom_end_icon"
android:hint="Hint text"
app:endIconMode="clear_text"
...>
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
../>
</com.google.android.material.textfield.TextInputLayout>
推荐阅读
- load-balancing - 我需要更多资源还是需要负载均衡器?
- sql - 如何在子字符串 SQL 中搜索特殊字符
- asp.net - 为 ASP/ASPX 文件上传设置什么内容类型?
- android - 在 ListView 中添加 TextView 跑马灯效果失败
- mysql - 从 dbeaver 连接到 MySQL 服务器给出检查“useSSL”是否设置为“true”
- r - R 在尝试使用 registerDoParallel 注册集群后卡住了
- python - python中具有o(n)顺序的大列表的快速列表减法
- react-native - 无法解析模块`@expo/vector-icons/fonts/Ionicons.ttf`
- c - printf 函数在输入之前不起作用
- php - 如何将 DI 容器注入控制器?