我有3个ListView的在我的活动,我想同时滚动它们所有在一起,所以我用Scrollview >>线性布局>> 3列表视图。但还是他们每个人单独在这里滚动 是XML代码:Listview doesnt scroll synchrologicly
<?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。 – RobCo