如何在 EditText 上添加图像 [英] How can I add an image on EditText

查看:22
本文介绍了如何在 EditText 上添加图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 EditText 中动态添加图片.是否可以?

I want to dynamically add image in EditText. Is it possible?

如果有人知道,请提供示例代码.

if anyone knows please give sample code for that.

推荐答案

如果是这样的:

就是你所说的,那么你只需要设置 Drawable{Right |左 |顶部 |xml中的bottom}属性,或者调用对应的java命令.

is what you're talking about, then you just need to either set the Drawable{Right | Left | Top | Bottom} property in the xml, or call the corresponding java command.

EditText text = (EditText)findViewById(R.id.text);
text.setCompoundDrawables(null, null, getResources().getDrawable(R.drawable.check_box), null);

这篇关于如何在 EditText 上添加图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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