Search code examples
androidandroid-layoutscrollviewimageswitcher

Android: ImageSwitcher inside Scrollview places image at bottom of the screen


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>

Solution

  • 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.