Android, How to add ScrollView into screen which has some list items?

14,305

Solution 1

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>

Solution 2

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

Solution 3

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.

Share:
14,305
Hesam
Author by

Hesam

Do you want to know more about me, find me in LinkedIn

Updated on July 21, 2022

Comments

  • Hesam
    Hesam almost 2 years

    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?

  • Hesam
    Hesam about 12 years
    Thank you, i did this but result was same, i couldn't scroll the screen.
  • Hesam
    Hesam about 12 years
    Thank you, i did this but result was same, i couldn't scroll the screen.