2

我有一个包含多行的列表视图,其中一行必须是包含多行的列表视图,但只需要显示其中的 2 个,其余的仅在滚动时显示。我在布局文件的列表视图中添加了一个带有 LinearLayout 的 ScrollView,并且我在 java 文件中添加了行的内容。ScrollView 似乎不能很好地滚动。有没有更好的方法来实现这一目标?这是我的布局文件。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<ListView
    android:id="@android:id/list"
    android:layout_width="1px"
    android:layout_height="1px"
    android:layout_weight="1"
    android:cacheColorHint="#00000000"
    android:scrollbars="vertical" >
</ListView>

<RelativeLayout
    android:id="@+id/listItem"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <ImageView
        android:id="@+id/formImage"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:scaleType="fitXY" />

    <include layout="@layout/vertical_list_item_title_area" />
</RelativeLayout>


    <ScrollView
    android:id="@+id/scrollView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:fillViewport="true"
    android:layout_weight="1">

    <LinearLayout
        android:id="@+id/childListLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

    </LinearLayout>
</ScrollView>

<com.illumemobile.testapp.Classes.SCClasses.SCActivities.SCCustomActivities.SCCustomGallery
    android:id="@+id/horizontallistview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scaleType="fitXY"
    android:spacing="33dip" />

4

2 回答 2

3

ListViews 内部的 ScrollViews 是一个非常非常糟糕的主意。它不仅让用户感到困惑,而且系统在确定哪个 View 应该获取触摸事件方面也存在问题。

我建议重新考虑您的布局。

于 2012-10-02T16:15:31.630 回答
2

我建议制作一个 ScrollView,然后在滚动视图中制作一个 LinearLayout。在该 LinearLayout 中,您可以将更多 LinearLayouts 一个或多个项目作为子项。我认为这会接近你想要做的事情......我更喜欢使用 ScrollViews 和 LinearLayouts 而不是尝试处理 ListViews。根据我的经验,LinearLayouts 比 ListViews 动态得多。-希望这可以帮助

于 2012-10-02T16:21:25.413 回答