1

I have 3 Listview's in my activity and i want to scroll all of them together at the same time, so i used Scrollview >> linear layout >> 3 listview. but still each of them scroll separately here is the xml code:

<?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>
Nir Cohen
  • 25
  • 8
  • ListView handles it's own scrolling, so you should generally not put it inside a ScrollView parent. Either refactor your code to use a single ListView (with a custom adapter to merge to different content), or only a ScrollView with one linear layout. – RobCo Apr 15 '17 at 12:30

1 Answers1

1

Do not use ListView(s) into ScrollView.

Use RecyclerViews into NestedScrollView.

Check this Question

Also I do not know what you want to achieve but You can use different type of items into one ListView or RecyclerView.

Community
  • 1
  • 1
Oğuzhan Döngül
  • 7,856
  • 4
  • 38
  • 52