How to remove white space showing on top of scrollView

荒凉一梦 提交于 2019-12-11 06:43:31

问题


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>

回答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.




回答2:


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



来源:https://stackoverflow.com/questions/26556307/how-to-remove-white-space-showing-on-top-of-scrollview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!