2017-04-15 76 views
1

我有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> 
+0

ListView处理它自己的滚动,所以你通常不应该把它放在一个ScrollView父类中。重构代码以使用单个ListView(使用自定义适配器合并到不同的内容),或者只使用一个线性布局的ScrollView。 – RobCo

回答

1

你不应该把一个ListView滚动型里面,因为ListView控件类实现了自己的滚动,它只是不接受手势,因为他们都由父ScrollView处理。

Your Question has Answer Here

1

不要使用ListView控件(S)为滚动型。

将RecyclerViews用于NestedScrollView。

入住这Question

此外,我不知道你要实现什么,但你可以使用不同类型的项目为一体的ListView或RecyclerView。