1

I am trying to make a picture with my app but it doesn't work.

I'm implementing a function to record a picture with my app, the result of this is a URI.

This URI I have in my activity, with this I try to show the user the recorded picture, to realize this I use from the imageview the method setImageUri ... but it doesn't work for me.

The thing I'm confused about, the imageview exist, in the screen I see the dimension.

In this case, the code that I have implemented

ImageView imgView = new ImageView(activityContext);
        imgView.setImageURI(Uri.parse(captureImg.toString()));
        mainFrame.addView(imgView, 100, 100);

another solutions:

Drawable d = Drawable.createFromPath(captureImg.toString());
        ImageView imgView = new ImageView(activityContext);
        imgView.setImageDrawable(d);
        mainFrame.addView(imgView, 100, 100);

This both doesn't work for me, I have to try to use any solutions with Bitmap but this doesn't work me too.

Greets

MLavoie
  • 9,671
  • 41
  • 36
  • 56
Manu Zi
  • 2,300
  • 6
  • 33
  • 67
  • ok now i solved the problem with the following link http://stackoverflow.com/questions/3331527/android-resize-a-large-bitmap-file-to-scaled-output-file – Manu Zi Dec 03 '13 at 11:08

3 Answers3

3

Please make sure your "UI code" (imgView.setImageDrawable(d);) run on UIthread Take this for reference: http://www.vogella.com/articles/AndroidPerformance/article.html

vanloi999
  • 485
  • 4
  • 13
0

Try as:

ImageView imgView = new ImageView(activityContext);
LinearLayout.LayoutParams vp = new LinearLayout.LayoutParams
                          (LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
imgView.setLayoutParams(vp);
imgView.setMaxHeight(100);
imgView.setMaxWidth(100);
imgView.setImageURI(Uri.parse(captureImg.toString()));
mainFrame.addView(imgView);

you are not adding LayoutParams to dynamically created ImageView

ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213
0

---Try this---

ImageView imgView = new ImageView(activityContext);
imgView.setImageURI(Uri.parse(captureImg.toString()));
mainFrame.addView(imgView, new LinearLayout.LayoutParams(200,200));
Ajay S
  • 48,003
  • 27
  • 91
  • 111