ScrollView里面的视图并不占用所有的位置

我有一个ScrollView内的RelativeLayout。 我的RelativeLayout有android:layout_height="match_parent"但视图不占用整个大小,就像一个wrap_content。

有没有办法让真正的fill_parent / match_parent行为?

我的布局:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:id="@+id/top" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:scaleType="fitXY" android:src="@drawable/top" /> <ImageView android:id="@+id/header" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/top" android:scaleType="fitXY" android:src="@drawable/headerbig" /> <ImageView android:id="@+id/logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/header" android:layout_centerHorizontal="true" android:layout_marginBottom="3dp" android:src="@drawable/logo" /> <ScrollView android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_above="@+id/bottom" android:layout_below="@+id/logo" android:background="@drawable/background" > <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:id="@+id/dashboard01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/dashboard02" android:layout_centerHorizontal="true" android:layout_marginBottom="30dp" android:src="@drawable/dashboard01" android:visibility="visible" /> <ImageView android:id="@+id/dashboard02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:layout_alignParentRight="true" android:layout_marginRight="10dp" android:src="@drawable/dashboard02" /> <ImageView android:id="@+id/dashboard03" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/dashboard02" android:layout_centerHorizontal="true" android:layout_marginTop="40dp" android:src="@drawable/dashboard03" android:visibility="visible" /> </RelativeLayout> </ScrollView> <ImageView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/logo" android:layout_centerHorizontal="true" android:scaleType="fitXY" android:src="@drawable/bar" /> <ImageView android:id="@+id/bottom" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:scaleType="fitXY" android:src="@drawable/bottom" /> </RelativeLayout> 

尝试添加android:fillViewport="true"到您的ScrollView

请记住, android:layout_height=”fill_parent”意思是“设置高度父母的高度”。这显然不是你想要什么时使用ScrollView 。 毕竟,如果ScrollView的内容总是和自己一样高的话,它就变得毫无用处了。 要解决这个问题,你需要使用名为android:fillViewport的ScrollView属性。 当设置为true时,如果需要,此属性会导致滚动视图的子级展开到ScrollView的高度。 当孩子高于ScrollView ,该属性不起作用。

http://www.curious-creature.org/2010/08/15/scrollviews-handy-trick/