0

I am trying to insert multiple images in one editText. I have used following code to attach image to EditText

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

But the problem is it only attach one file and show, If i used array then only the last image is only show. at any how it only shows one Image. Is there any way to show multiple images in one Editbox. Thanks in advance.

Balban
  • 718
  • 3
  • 9
  • 24
  • Then maybe give more details on what you want. Its always possible, you just have to get really creative. You can programmitcally make imageViews and stack them in a relative layout if they have transparency and need to be on top of each other. – Anthony Graglia Jul 05 '11 at 05:50
  • I am tring to make an application in which I want to attach images from sdcard. when this attached , then it will appear like thumbnail in editText(may be we can use Textview). But I am still cannot be figure out How can I do that. Drawable Layer seems to be very complex for this situation. – Balban Jul 05 '11 at 07:01
  • You should use a gallery in a relative layout which will allow you to place a textview over it. Or override the gallery and put a textview in each image in the baseadapter or a listview... can you ssupply a graphic or what you are looking for or link...? It seems you are going about it the wrong way. – Anthony Graglia Jul 05 '11 at 08:48

3 Answers3

1

Because you can only have one background.... if you want more then there is a layer Drawable which you can use and also you can put the button in a frame layout and add a couple of imageViews below/over it for the rest of the images.

But the best solution will probably be instead of having a couple of bitmaps to just make a single one in Photoshop or equivalent photo editing app and place that one.

DArkO
  • 15,880
  • 12
  • 60
  • 88
  • Here is an example using shapes, but this easily can be converted to drawables from resources. http://stackoverflow.com/questions/4381033/multi-gradient-shapes – DArkO Jul 04 '11 at 14:35
0

According to docs: http://developer.android.com/reference/android/view/View.html#setBackgroundDrawable(android.graphics.drawable.Drawable)

You are not able to provide more than one Drawable item in argument

And I don't know if you understand what is .setBackgroundDrawable(d) method purpose, but it is not meant to be used for displaying images inside text but to set Background of EditText View.

So you're not inserting images in EditText but setting its background,

look for some Rich Text Edit components usable for Android
such as http://code.google.com/p/android-richtexteditor/
or others..

Marek Sebera
  • 39,650
  • 37
  • 158
  • 244
0

You can probably use a LayerDrawable with the constructor LayerDrawable(Drawable[] layers) to chain together several images and display them as an EditText's background, though as Marek said, I suspect you're looking for something other than setting images in the background.

shilgapira
  • 1,216
  • 1
  • 10
  • 6