1

I have the following scrollView. Everything works exactly as I want, except: there is a white space between the top of the scrollView and the top of the ImageView. What I want is for the image to be flushed at the top. It would be great too if the scrollView does not scroll past the bottom edge of the image as well. Thanks for all suggestions.

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:scrollbars="none" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/welcome"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="top"
            android:scaleType="fitCenter"
            android:src="@drawable/welcome_page" />
    </LinearLayout>
</ScrollView>
Katedral Pillon
  • 14,534
  • 25
  • 99
  • 199
  • i don't know what "white space" you are referring to (maybe some pic? ) but did you try adjustViewBounds? – pskink Oct 25 '14 at 10:07

2 Answers2

1

To remove the top space, try using

android:scaleType="fitStart"

in the ImageView. As for the bottom space removal, maybe someone else can help you with that.

Konsol Labapen
  • 2,424
  • 2
  • 15
  • 12
  • ok so this worked. but I need to limit the scrollable height of the scrollview so that once the bottom of my image is reached, the scrollview should stop scrolling. Right now it does for a whole additional screen height. Thanks +1. – Katedral Pillon Oct 24 '14 at 22:15
  • I figured how to remove the bottom height by setting the ImageView to a fixed height instead of the wrap_content. – Katedral Pillon Oct 25 '14 at 01:13
  • Actually I was wrong about that fix: it only worked on my Galaxy S5. When I tried running it on my LG (android api 16) it still showed the bottom space. – Katedral Pillon Oct 25 '14 at 03:33
0

Try adding android:layout_marginTop="-2sp" to your LinearLayout. This will move LinearLayout a bit higher, hiding the space.

Gowthaman M
  • 8,057
  • 8
  • 35
  • 54
  • The space I am talking about is about a whole screen tall. And I want something more systematic than some magic number: unless that magic number could somehow be guaranteed to work well on all devices. This is android after all. – Katedral Pillon Oct 24 '14 at 21:53