Android edittext前面加图标
时间: 2023-08-18 22:14:44 浏览: 244
要在Android EditText前面加图标,可以使用drawableLeft属性。在EditText的布局文件中,添加以下代码:
```xml
<EditText
android:drawableLeft="@drawable/icon"
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter text" />
```
其中,@drawable/icon是你要显示的图标资源的名称。这样就可以在EditText前面添加一个图标了。\[3\]
#### 引用[.reference_title]
- *1* *2* [Android EditText 属性汇总](https://blog.csdn.net/weixin_44177244/article/details/119798062)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [Android EditText中添加图标的简单方法](https://blog.csdn.net/qq_33462950/article/details/82866299)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]