0

I'm currently trying to build a Note making app and one of its feature is supposed to be Opening the camera,taking an image and I should display this image on the EditText along with other Text which is already present in the EditText.

I know how to Open the camera,saving the image and stuff but How do you add the Image I captured below/above an EditText?

I believe that we need ImageView to display images but how do I incorporate this in my app along with the EditText?

Something like this...

enter image description here

Kindly point me to anything which helps me in finding how to do it since I'm unable to find anything useful.

3 Answers3

1

Wrap the EditText in a LinearLayout, then add the ImageView to that LinearLayout. If you define it in xml, it should look like this:

<LinearLayout ...>
    <EditText .../>
    <ImageView .../>
</LinearLayout>
F43nd1r
  • 7,690
  • 3
  • 24
  • 62
  • Maybe you can enhance your response and try to tie to the question – Olimpiu POP Aug 31 '15 at 14:48
  • @OlimpiuPOP as the question is asking for general advice, and isn't very complex, I think my answer is satisfying. He asked for help on how to find out, not for a ready-to-use solution. – F43nd1r Aug 31 '15 at 14:54
  • Yes I'm aware of this but how do I add multiple images?Like I take an image and display it using the imageview but what if I want to take another image next... isn't your approach only if I want to add a single image? – Abinesh S Prabhakaran Aug 31 '15 at 14:55
  • 1
    @AbineshSPrabhakaran in that case, I would add the ImageViews in code. An LinearLayout can take theoretically endless ImageViews. – F43nd1r Aug 31 '15 at 15:03
  • This seems to be the only way I guess. Thanks for the quick replies. – Abinesh S Prabhakaran Aug 31 '15 at 15:11
1

You should be able to add an image directly into the editText by using html tags to do so. I'm not entirely sure on how to acquire uri reference to the image, but i assume thats not too hard.

Daniel Bo
  • 2,518
  • 1
  • 18
  • 29
  • Wow this is interesting.I'll look into this... and just a confirmation, are you asking me to use Html.ImageGetter? – Abinesh S Prabhakaran Aug 31 '15 at 15:07
  • 1
    in an Android textView and EditText you can use html tabs to format your text like '', but you can also use ''. So you dont have to create a large number of Views. – Daniel Bo Sep 01 '15 at 12:14
1
<LinearLayout orientaion:vertical  >
<EditText>
</EditText>
<ImageView>
</ImageView>
</LinearLayout>

If you want many ImageViews,You can create many at run time while taking photo.

ImageView view = new ImageView(context);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
Linear_layout.addView(view, lp);
SRB Bans
  • 3,096
  • 1
  • 10
  • 21