我有一个垂直布局作为其子的scrollView。此垂直布局具有背景属性。在这个垂直布局中,我有14个按钮堆叠在一起。它不会结束最后一个按钮底部的背景,而是继续添加相当多的我不想要的空间。这是XML文件的代码。Android ScrollView在页面底部留下额外的空间
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/mainbg"
android:orientation="vertical" >
<Button
android:id="@+id/maps"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/battingcages" />
<Button
android:id="@+id/collec"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/thebeyond" />
<Button
android:id="@+id/mut"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/css" />
<Button
android:id="@+id/ach"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/csite" />
<Button
android:id="@+id/button5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/crane" />
<Button
android:id="@+id/button6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/gas" />
<Button
android:id="@+id/button7"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/tif" />
<Button
android:id="@+id/button8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/lgtf" />
<Button
android:id="@+id/button9"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/pent" />
<Button
android:id="@+id/button10"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/slides" />
<Button
android:id="@+id/button11"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/treehouse" />
<Button
android:id="@+id/button12"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/space" />
<Button
android:id="@+id/button13"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/fight" />
<Button
android:id="@+id/button14"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/tower" />
</LinearLayout>
</ScrollView>
什么是绘制mainbg?是9.png吗?可绘制的XML资源?尝试把它拿出来,只是设置颜色为红色的东西,看看会发生什么。 – ksarmalkar
布局没问题。你能显示一个屏幕截图吗? – eleven
这是一个普通的.jpg,但后来我将它复制到draw9patch工具中并保存。不用找了。这里有一个截图:http://i.imgur.com/yghJXV9.png。另外我没有这个问题,当不使用scrollView和.jpg – Josh