0

I have an ImageView and I want this to be resized automatically. I mean, no matter the size of the image this myst be displayed with the same size but, this also must work for different screen sizes so I can not assign a specific value. This is the xml:

<ImageView
    android:id="@+id/image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="30"
    android:layout_gravity="center"        
    />

and this the code

imageFoto=(ImageView)v.findViewById(R.id.image);
url = new URL("http://54.76.186.59/Foto/Foto.jpg");
bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
imageFoto.setImageBitmap(bmp);
imageFoto.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
imageFoto.setAdjustViewBounds(true);
Cœur
  • 37,241
  • 25
  • 195
  • 267
user3815821
  • 397
  • 2
  • 3
  • 12
  • please post the entire layout xml – sddamico Aug 13 '14 at 18:34
  • I believe this is what you are looking for: http://stackoverflow.com/questions/8232608/fit-image-into-imageview-keep-aspect-ratio-and-then-resize-imageview-to-image-d – chrislegolife Aug 13 '14 at 18:42
  • Also have a look at http://stackoverflow.com/questions/3781790/how-do-i-make-my-imageview-a-fixed-size-regardless-of-the-size-of-the-bitmap – Sash_KP Aug 13 '14 at 19:06
  • have a look at picasso, it's an open source android image processing/caching library. VERY GOOD! http://square.github.io/picasso/ – Jesson Atherton Aug 13 '14 at 20:03

0 Answers0