I've to use listView inside a scrollView , for some reasons I can't use addHeader for addFooter .
When I set adapter to my listView , I change it heights but it's not working properly .
This is my code :
lv.setAdapter(ladap);
int totalHeight = 0;
for (int size = 0; size < ladap.getCount(); size++) {
View listItem = ladap.getView(size, null, lv);
listItem.measure(0, 0);
totalHeight += listItem.getMeasuredHeight();
}
ViewGroup.LayoutParams params = lv.getLayoutParams();
params.height = totalHeight + (lv.getDividerHeight() * (ladap.getCount() - 1));
lv.setLayoutParams(params);
lv.requestLayout();
This is the result :

as you can see, the listview is finished in the middle of the page but it still scrolls alot .
How to make it right ?