I've searched around for solutions to this problem, and the only answer I can find seems to be "don't put a ListView into a ScrollView". I have yet to see any real explanation for why though. The only reason I can seem to find is that Google doesn't think you should want to do that. Well I do, so I did.
So the question is, how can you place a ListView into a ScrollView without it collapsing to its minimum height?
try this, this works for me, I forgot where I found it, somewhere in stack overflow, i'm not here to explained it why it doesn't work, but this is the answer :).
EDIT !, I finally found out where I got the code. here ! : ListView inside ScrollView is not scrolling on Android
Instead of putting the listview inside Scrollview, put the rest of the content between listview and the opening of the Scrollview as a separate view and set that view as the header of the listview. So you will finally end up only list view taking charge of Scroll.
hey I had a similar issue. I wanted to display a list view that didn't scroll and I found that manipulating the parameters worked but was inefficient and would behave differently on different devices.. as a result, this is a piece of my schedule code which actually does this very efficiently.
Note: if you use this,
notifyDataSetChanged();
will not work as intended as the views will not be redrawn. Do this if you need a work aroundAlthough the suggested setListViewHeightBasedOnChildren() methods work in most of the cases, in some cases, specially with a lot of items, I noticed that the last elements are not displayed. So I decided to mimic a simple version of the ListView behavior in order to reuse any Adapter code, here it's the ListView alternative:
This will definitely work............
You have to just replace your
<ScrollView ></ScrollView>
in layout XML file with thisCustom ScrollView
like<com.tmd.utils.VerticalScrollview > </com.tmd.utils.VerticalScrollview >
You Create Custom ListView Which is non Scrollable
In Your Layout Resources File
In Java File
Create a object of your customListview instead of ListView like : NonScrollListView non_scroll_list = (NonScrollListView) findViewById(R.id.lv_nonscroll_list);