【问题标题】:ListView acting strange due to ScrollView?由于 ScrollView,ListView 表现得很奇怪?
【发布时间】:2012-08-05 20:28:39
【问题描述】:

截图:

如上图所示,由于某种原因,在使用 ScrollView 时,我的 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>

【问题讨论】:

    标签: android listview background scrollview items


    【解决方案1】:

    您不能在 ScrollView 中放置 ListView。那是不可能的。因为那时 ListView 有两个选项可以滚动浏览内容,正如您所愿。这是行不通的。

    如果您想在 ListView 下方或上方显示内容并希望它随它一起滚动,您可能必须创建一个自定义 View。

    更多信息:

    https://groups.google.com/forum/m/?fromgroups#!topic/android-beginners/LRpLgGOy2Pc

    编辑: 我建议你使用这个: https://github.com/thiagolocatelli/android-uitableview 它是一个自定义 ListView,您可以在 ScrollView 中设置它

    【讨论】:

      猜你喜欢
      • 2013-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-22
      • 2014-12-12
      • 2012-11-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多