0

Hy there, i am writing an application in which a Bitmap is loaded from the Gallery and displayed in a ImageView. I am using the following XML for the ImageView:

<ImageView 
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:adjustViewBounds="true"
        android:scaleType="fitCenter"
        android:padding="3dp"
        android:background="@drawable/back"
        android:contentDescription="@string/contentDis"/>

My Target here is to center the ImageView horizontally and it should fit the dimensions of the loaded Bitmap (with a border from the background resource). But there seems to be a Problem: While this works for most Images some, especially those who have a much greater width than height aren't displayed. The ImageView shows the background only. I have already tried different scaleTypes but nothing solved the issue. But when i change the width of the ImageView in XML to fill_parent the Image is displayed. Why does this happen and how to solve this issue?

BhavikKama
  • 8,566
  • 12
  • 94
  • 164
ZeroTek
  • 1,302
  • 1
  • 11
  • 30
  • Could you attach a few screenshots? – Kumar Bibek Jun 11 '13 at 10:07
  • if the image is larger you can scale them down to the require height and width. http://stackoverflow.com/questions/16765899/out-of-memory-error-with-bitmap/16766123#16766123. and this http://developer.android.com/training/displaying-bitmaps/load-bitmap.html – Raghunandan Jun 11 '13 at 10:20
  • Well, scaling is not a problem here they are scaled down. I tried around and it only happens when the width is much greater than the hight of the bitmap. I also tried to set the width of the ImageView to fill_parent and scale the bitmap myself. It worked but this is not want i want. I don't want to fill out the hole screen if the bitmap is smaller. – ZeroTek Jun 11 '13 at 13:58

0 Answers0