2

in my activity, i have three lists. after running the application, the screen is not scroll-able. i can scroll the list which is on top of others but i can't scroll the whole of page. I tried to add ScrollView into my xml layout but lint says that "The vertically scrolling ScrollView should not contain another vertically scrolling widget (ListView)".

How to make my screen scrollable?

Avadhani Y
  • 7,566
  • 19
  • 63
  • 90
Hesam
  • 52,260
  • 74
  • 224
  • 365

4 Answers4

2

Try this way

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

    <LinearLayout android:id="@+id/GlobalLayout" 
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:orientation="vertical" >

        <ListView android:id="@+id/ListView1"
                  android:choiceMode="multipleChoice"
                  android:layout_height="100dip"
                  android:layout_width="fill_parent" />
       <ListView android:id="@+id/ListView2"
                  android:choiceMode="multipleChoice"
                  android:layout_height="100dip"
                  android:layout_width="fill_parent" />
       <ListView android:id="@+id/ListView3"
                  android:choiceMode="multipleChoice"
                  android:layout_height="100dip"
                  android:layout_width="fill_parent" />

    </LinearLayout>

</ScrollView>
Vinayak Bevinakatti
  • 40,205
  • 25
  • 108
  • 139
1

enter image description here

<ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <ListView
                android:id="@+id/listView1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1" >
            </ListView>

        </LinearLayout>

    </ScrollView>

Scrollview supports one child layout so make the listview inside the scroll so you will get what you want.

Sreedev
  • 6,563
  • 5
  • 43
  • 66
1

It doesn't work because android don't know with which view he should scroll, so putting a listview in a scrollview its not a bright idea. try to use visibilty attribute, use to HIDE the view that you finich to work with and set VISIBLE the new. or use one ListView and try to populate and remove items after finishing and starting an instruction. hope that help you

Dhanuka
  • 2,826
  • 5
  • 27
  • 38
hediw
  • 11
  • 2
0

What you can do is that you can add header and footer into your list view by inflating them. Create three xml layououts and add them in listview using header and footer.

    View headerView = View.inflate(this, R.layout.layout_name, null);
    lv.addHeaderView(headerView);

use it before setting adapter. lv is listview.

Bharat Sharma
  • 3,926
  • 2
  • 17
  • 29