0

My linear layout having two list views, when i add items in second list view, its not expanding. its getting scrolled automatically,

i have used match_parent in my linear layout, even though the second list view (getting scrolled instead of expanding) or the linear layout is not expanding.

Can anyone please help me to expand the list view or the linear layout.

problem in linear layout or the second list view?

but the first list view expanding properly.

fragment_one.xml

        <LinearLayout
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:layout_weight="1"
                android:descendantFocusability="blocksDescendants"
                android:padding="10dip" >

                <ListView
                    android:id="@+id/list_nation"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dip"
                    android:background="#B29090"
                    android:nestedScrollingEnabled="true">
                </ListView>

                <ListView
                    android:id="@+id/list_regional"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dip"
                    android:background="#4A9C67"
                    android:focusable="false"
                    android:nestedScrollingEnabled="true">
                </ListView>

            </LinearLayout>
Happy
  • 1,031
  • 10
  • 26

1 Answers1

0

When you add multiple scrolls in a single screen it always shows problems. Because they conflict with each other. There are two solution for your problem.

  1. If you want to keep your each listview to take half screen then add "weightsum = 100" in your main linear layout and set weight of both listviews to "50".
  2. If you want your first list to scroll till end and at the end of first you want the second one to start scrolling, then calculate the height of your lists on run time and assign the calculated height to your listviews. Check this: Android: How to measure total height of ListView
Zohaib Hassan
  • 984
  • 2
  • 7
  • 11