-1

I have a ListView inside of a ScrollView - but my issue is that I don't want the Listview to scroll, instead I want the listview to be fully expanded and just scroll the ScrollView up and down to see the items of the ListView. Can someone recoment a solution?

Here is my layout:

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


        <ListView
            android:id="@+id/user_list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:divider="@null"
            android:visibility="gone" />

</ScrollView>

P.S. I know that this is bad practice but I need this thing anyway

Darko Petkovski
  • 3,892
  • 13
  • 53
  • 117
  • i don't really understand your question but what if the listview has like a thousand items,do you expect them to be expanded and fit in the phone screen? – danidee Sep 27 '14 at 07:32
  • @danidee actually it cannot have more than 10 items – Darko Petkovski Sep 27 '14 at 07:35
  • 1
    ok,but i think putting a listview inside a scrollview is a bad idea because the ListView will not stretch to its full height.have you tried reducing the height of the individual cells in the listview that way the listview will fit in the screen if you have just 10 items – danidee Sep 27 '14 at 07:41
  • 1
    have you checked out this link http://stackoverflow.com/questions/18367522/android-list-view-inside-a-scroll-view it talks about scrollviews and listviews...Hope it helps – danidee Sep 27 '14 at 07:43

3 Answers3

0

set this property in your scrollview android:fillViewport="true" it will work

0

two scrolling views cannot be inside one another. Follow the following link: ListView inside ScrollView is not scrolling on Android

Community
  • 1
  • 1
Prince
  • 496
  • 3
  • 12
0

You can consider this. But the ListView's height must be hard coded and it does recycling which slightly deviates from your requirement. But ListView without recycling, as you mentioned, is not a good practice. So try to achieve the thing with recycling as described in the above link.

Durgadass S
  • 1,098
  • 6
  • 13