Abinesh S Prabhakaran
Abinesh S Prabhakaran

Reputation: 337

Android: How to add images/ImageView in on an EditText

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.

Upvotes: 0

Views: 1661

Answers (3)

Sourabh Bans
Sourabh Bans

Reputation: 3134

<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);

Upvotes: 1

F43nd1r
F43nd1r

Reputation: 7749

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>

Upvotes: 1

Daniel Bo
Daniel Bo

Reputation: 2518

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.

Upvotes: 1

Related Questions