Why is my Android ListView not scrolling?


I have an android <ListView /> layout that is pretty long: 1217 lines.

Within this layout I have embedded two <ListView> sections. Following is an extremely abridged edition of my layout:

<?xml version="1.0" encoding="utf-8"?>
<layout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
		
        <!-- width = match / height = wrap -->
        <include layout="@layout/layout_header" />
		
        <View
            android:layout_width="match_parent"
            android:layout_height="1dp" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
			
	        <LinearLayout
		        android:layout_width="0dp"
		        android:layout_height="wrap_content"
		        android:layout_weight="1"
		        android:orientation="vertical">

		        <TextView
		            android:layout_width="wrap_content"
		            android:layout_height="wrap_content" />
		        <ListView
		            android:layout_width="match_parent"
		            android:layout_height="0dp" />

	        </LinearLayout>
		
	        <LinearLayout
		        android:layout_width="0dp"
		        android:layout_height="wrap_content"
		        android:layout_weight="1"
		        android:orientation="vertical">

		        <TextView
		            android:layout_width="wrap_content"
		            android:layout_height="wrap_content" />
		        <ListView
		            android:layout_width="match_parent"
		            android:layout_height="0dp" />

	        </LinearLayout>
			
        </LinearLayout>
		
        <!-- width = match / height = wrap -->
        <include layout="@layout/..." />

        <!-- Three VERY LONG <GridLayout /> Sections -->		
        <GridLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
        </GridLayout>
        <GridLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
        </GridLayout>
        <GridLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
        </GridLayout>

        <CheckBox
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>
</layout>

The entire layout is quite long, and needs the ability to scroll in general.

Originally, the top view underneath <layout /> was <ScrollView /> so that users could see everything by scrolling up and down. I received a warning from Android Studio that I cannot use a scrollable view inside another scrollable view, so I turned the <ScrollView /> into a <LinearLayout /> and now not only are my <ListView /> views not scrolling, but neither is the rest of the page.

I have every top-level view width="match_parent" and height="wrap_content", but it still isn't working.

So, how can I get the entire layout to scroll and the <ListView /> to scroll within the layout?

Disclaimer: I don't believe this is the same as other StackOverflow posts about this, as all the advice of "remove <ScrollView>" has not worked for me.

1
Feb 11 at 7:25 PM
User AvatarBrian
#android#android-listview#android-scrollview

No answer found for this question yet.