0

So I created a simple little app that contains rather tall images inside an ImageSwitcher and due to the height of the images, I've wrapped the ImageSwitcher inside a ScrollView (so the entire image is eventually visible). The interesting thing is that the Image doesnt start at the top of the ScrollView but rather the bottom. The scrolling all works correctly, but I was just curious as to why the top of the image is almost at the bottom of the device screen.

Does anyone know what is causing this behavior?

My images are large drawables (800x600) that are obviously being scaled down in order to fit in the device window, but that still doesn't explain why there is such a large amount of empty space above the image.

I would prefer to just scroll the ImageSwitcher itself but that hasn't worked thus far.

Here is my layout:

<ScrollView android:id="@+id/scroll"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">
     <ImageSwitcher android:id="@+id/switcher"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:background="#FFFFFF"/>
</ScrollView>
Shawn
  • 2,406
  • 1
  • 26
  • 31

2 Answers2

1

Try to call ImageView.setAdjustViewBounds(true) in addition to setScaleType. If you still have problems with your ImageView (inside ImageSwitcher) taking more space than needed, try to peek at the ImageView with the hierarchyviewer in the SDK tools.

1

My suspicion is that the images are being displayed due to the resolution of the original image. I set ImageView.setScaleType(ScaleType.FIT_START); and this appears to have fixed the problem.

Shawn
  • 2,406
  • 1
  • 26
  • 31
  • this fixes the problem of extra space above the image, but the extra space is now below the image that is apparent if you add a new control after the ImageView... Any ideas? – Hadi Apr 20 '12 at 16:39