Listview不会同步滚动

时间:2017-04-15 12:19:28

标签: android listview

我的活动中有3个Listview,我想同时将它们全部滚动在一起,所以我使用了Scrollview>>线性布局>> 3列表视图。但他们每个人都会分开滚动 这是xml代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_order_items"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.nir.nestleapp.OrderItemsActivity">
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="410dp">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="500dp"
        android:orientation="horizontal">
        <ListView
            android:layout_width="125dp"
            android:id="@+id/ItemNameList"
            android:layout_height="372dp">

        </ListView>

        <ListView
            android:id="@+id/ItemPriceList"
            android:layout_width="125dp"
            android:layout_height="fill_parent"
            android:layout_alignParentTop="true"
            android:layout_toEndOf="@+id/QuantityList">
        </ListView>
        <ListView
            android:id="@+id/QuantityList"
            android:layout_width="125dp"
            android:layout_height="match_parent"
            android:layout_alignParentTop="true"
            android:layout_toEndOf="@id/ItemPriceList">

        </ListView>

    </LinearLayout>
    </ScrollView>
    <Button
        android:text="Button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="10dp"
        android:id="@+id/button3" />

</RelativeLayout>

2 个答案:

答案 0 :(得分:1)

你不应该将一个ListView放在ScrollView中,因为ListView类实现了自己的滚动,它只是不接收手势,因为它们都是由父ScrollView处理的。

Your Question has Answer Here

答案 1 :(得分:1)

不要将ListView用于ScrollView。

将RecyclerViews用于NestedScrollView。

选中此Question

此外,我不知道您想要实现什么,但您可以将不同类型的项目用于一个ListView或RecyclerView。