Android Listview不同步滚动
我的活动中有3个Listview,我想同时滚动它们,所以我使用了Scrollview>>线性布局>>3 Listview。但它们仍然各自滚动 以下是xml代码:Android Listview不同步滚动,android,listview,Android,Listview,我的活动中有3个Listview,我想同时滚动它们,所以我使用了Scrollview>>线性布局>>3 Listview。但它们仍然各自滚动 以下是xml代码: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/to
<?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>
您不应该将ListView放在ScrollView中,因为ListView类实现了自己的滚动,它只是不接收手势,因为它们都由父ScrollView处理 不要在ScrollView中使用ListView 在NestedScrollView中使用RecyclerViews 检查这个
另外,我不知道您想要实现什么,但您可以在一个ListView或RecyclerView中使用不同类型的项。ListView处理它自己的滚动,因此您通常不应该将它放在ScrollView父级中。重构代码以使用单个ListView(使用自定义适配器合并到不同的内容),或者仅使用具有一个线性布局的ScrollView。