我正在尝试在一个editText中插入多个图像。我已经使用以下代码将图像附加到EditText

txt = (EditText)findViewById(R.id.text);
Bitmap bitmap = BitmapFactory.decodeFile(attach);
Drawable drawable = new BitmapDrawable(bitmap);
txt.setBackgroundDrawable(drawable);


但问题是它仅附加一个文件并显示,如果我使用数组,则仅显示最后一个图像。无论如何,它仅显示一个图像。有没有办法在一个Editbox中显示多个图像。提前致谢。

最佳答案

根据文档:http://developer.android.com/reference/android/view/View.html#setBackgroundDrawable(android.graphics.drawable.Drawable

您不能在参数中提供多个Drawable项

而且我不知道您是否了解.setBackgroundDrawable(d)方法的用途是什么,但是它并不是用来在文本内部显示图像,而是用来设置EditText视图的背景。

因此,您不是要在EditText中插入图像,而是要设置其背景,

寻找一些适用于Android的Rich Text Edit组件
http://code.google.com/p/android-richtexteditor/
或其他

10-08 03:15