1

I am using a scrollView having a linear layout and a ListView. initially the size of scroll view is 0 i.e height. whenever i run the code, ListView displays elements and scroll view height increases. but when ListView is emptied, size of scroll view remains as it is as it was stretched to.

I use scrollTo(0,0) to get to top, but i want to resize the scrollView as it was initially. can somebody tell me how to do so? thanks.

p.s: i also used setLayoutParams(new RelativeLayout.LayoutParams(0,0)); but that completely removed the linear layout withen the scroll view.

Andro Selva
  • 53,910
  • 52
  • 193
  • 240
Jim
  • 11
  • 1
  • It is not recommended to use a list view in scroll view.Unexpected error may occur when you scroll to the last of the list view. – Rasel Jun 28 '11 at 04:22
  • http://nex-otaku-en.blogspot.com/2010/12/android-put-listview-in-scrollview.html – Waza_Be Jun 28 '11 at 04:37

1 Answers1

0

Please have a look at Romain Guy comments here:

How can I put a ListView into a ScrollView without it collapsing?

As he was in charge of ListView in ANdroid developpement, I guess we should trust him ;-)

Community
  • 1
  • 1
Waza_Be
  • 39,407
  • 49
  • 186
  • 260
  • no no, i am not having trouble putting listview in scroll view, i solved that problem by manually changing size of listview items. my problem is : scrollview size increases when list size increses. but when listview is emptied after that, i want the scroll view to resize to original size it was before. right now it remains elonganated, i.e user can scroll down even when list is cleared. – Jim Jun 28 '11 at 05:03
  • in scroll view try using layout_height as wrap content – Rasel Jun 28 '11 at 08:51