Search code examples
androidlistlistviewscrollscrollable

Android ListView scrolls the entire screen


I have created a layout containing many linear layouts, and I have, in one of the linear layouts, 3 ListViews set side by side. I want to make each one of them scrollable, but singularily. For example, I want to be able to scroll one of them without anything else being affected.

Right now, if I set "android:nestedScrollingEnabled="true"" for any one of the lists, the entire screen scrolls. I want the scrolling of the list to be confined to the layout the list is in (so I can scroll the list and the rest of the screen stays in place).

How can I do that? So far, it's either no scrolling at all, or scrolling the entire screen. I just want the list to scroll.

Thanks!

PS: Here's how the relevant part of the XML looks like (nothing special about it):

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:layout_marginBottom="@dimen/list_vertical_margin">

       <ListView
            android:id="@+id/realtime_vehicle_list"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1" />

        <ListView
            android:id="@+id/realtime_errors_list"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1" />

        <ListView
            android:id="@+id/realtime_depot_list"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1" />
</LinearLayout>

Solution

  • I've figured it out. Apparently, the layout "continues" beyond the screen. I only put a few more elements to test if it scrolls, but in reality, the reason why only the 3rd list was scrolling and the other two weren't is because the 3rd list had more elements, and it went beyond its limits. That's why it was scrolling.

    I was equating the "going out of the screen" with the idea that the list should scroll, but it's just a design problem - the operating system didn't think that the list was going off the screen.

    As soon as I put more elements into the other two lists, they are now all scrolling.