由于ScrollView的ListView行事奇怪?
问题描述:
如可以在图片中可以看出上面由于某种原因,我在ListView中使用滚动型时得到的任何一个奇怪的白色区域。如果我删除ScrollView的白色区域没有消散,但不幸的是我必须在我的界面中使用ScrollView。如果我用物品填写清单,那么白色的“区域”仍然存在,而是放置在物品下方。
以前有人看过这个吗?我怎样才能删除它,而不删除我的ScrollView由于某种原因使它出现?我试图改变所有不同类型的设置,比如fill_parent/wrap_content/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>
答
您不能在ScrollView中放置ListView。那是不可能的。因为那样ListView有两个选项可以滚动浏览内容,就像你会的那样。这是行不通的。
如果要在ListView之上或之上显示内容,并希望它随滚动而移动,则可能必须创建自定义视图。
欲了解更多信息:
https://groups.google.com/forum/m/?fromgroups#!topic/android-beginners/LRpLgGOy2Pc
编辑: 我会建议你使用这样的: https://github.com/thiagolocatelli/android-uitableview 它是一个自定义的ListView,你可以滚动型内设置
伊夫editted我的回答 – Ahmad 2012-08-05 21:25:49