Android 由于ScrollView而导致ListView行为异常?
截图: 从上图中可以看出,由于某种原因,当使用滚动视图时,我的listView中出现了一个奇怪的白色空白区域。如果我删除ScrollView,白色的空白区域将消失,但不幸的是,我必须在界面中使用ScrollView。如果我用项目填充列表,白色的“区域”仍然存在,并被放置在项目下方 有人见过这个吗?我怎样才能在不删除ScrollView的情况下删除它,而ScrollView由于某种原因使它出现?我尝试更改所有不同类型的设置,例如填充父项/包装内容/0dip,但迄今为止没有成功 如果你知道什么,请帮忙Android 由于ScrollView而导致ListView行为异常?,android,listview,background,scrollview,items,Android,Listview,Background,Scrollview,Items,截图: 从上图中可以看出,由于某种原因,当使用滚动视图时,我的listView中出现了一个奇怪的白色空白区域。如果我删除ScrollView,白色的空白区域将消失,但不幸的是,我必须在界面中使用ScrollView。如果我用项目填充列表,白色的“区域”仍然存在,并被放置在项目下方 有人见过这个吗?我怎样才能在不删除ScrollView的情况下删除它,而ScrollView由于某种原因使它出现?我尝试更改所有不同类型的设置,例如填充父项/包装内容/0dip,但迄今为止没有成功 如果你知道什么,请
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/orginalbild"
android:fillViewport="true"
android:gravity="center|top"
android:orientation="vertical"
android:stretchColumns="1"
android:weightSum="1.0">
<TableRow
android:paddingTop="3dp" >
<TextView
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="0.04">
</TextView>
<EditText
android:id="@+id/search_task_field"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="0.7"
android:hint="@string/SearchTaskHint"
/>
<ImageButton
android:id="@+id/search_task_button"
android:layout_width="0dip"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_weight="0.22"
android:src="@drawable/find3" />
<TextView
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="0.04"
android:visibility="invisible"
>
</TextView>
</TableRow>
<TableRow
android:paddingTop="0.9dp"
android:paddingRight="0.9dp"
android:paddingLeft="0.9dp"
android:background="#90767878"
android:paddingBottom="0.9dp"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_marginBottom="20dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@+id/search_task_list"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#FFFFFF"
android:gravity="left"
/>
</TableRow>
</TableLayout>
</ScrollView>
不能在滚动视图中放置列表视图。那是不可能的。因为ListView有两个选项可以滚动浏览内容,如您所愿。这是行不通的 如果您想在ListView下方或上方显示内容,并希望它与ListView一起滚动,您可能需要创建一个自定义视图 有关更多信息: 编辑: 我建议您使用以下方法:
这是一个自定义的ListView,您可以在ScrollView中设置它您不能在ScrollView中放置ListView。那是不可能的。因为ListView有两个选项可以滚动浏览内容,如您所愿。这是行不通的 如果您想在ListView下方或上方显示内容,并希望它与ListView一起滚动,您可能需要创建一个自定义视图 有关更多信息: 编辑: 我建议您使用以下方法: 这是一个自定义列表视图,您可以在ScrollView中设置它