I have a custom image background that fills the entire screen behind a ListView.
The ListView has a header that contains some data, then a transparent 10dp margin(allowi
I hacked it by adding a colored footer. The footer was a LinearLayout containing a View called "fill" set to 5dp height w/ my desired bg color.
After populating & scaling my list header (prior code), I then adjusted the footer to fill in the remaining screen space:
...
int totHeight = getTotalHeightofListView();
if((mHeader.getMeasuredHeight() + totHeight) < mList.getMeasuredHeight())
addFooterFill(mHeader.getMeasuredHeight() + totHeight);
}
protected int getTotalHeightofListView() {
ListAdapter LvAdapter = mList.getAdapter();
int totHeight = 0;
for (int i = 0; i < mAdapter.getCount(); i++) {
View mView = mAdapter.getView(i, null, mList);
mView.measure(
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
totHeight += mView.getMeasuredHeight();
}
return totHeight;
}
protected void addFooterFill(int sizeUsed){
View fill = (View) mFooter.findViewById(R.id.fill);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) fill.getLayoutParams();
params.height = mList.getMeasuredHeight() - sizeUsed;
fill.setLayoutParams(params);
}
In theory this should work even if you already have a footer. You're essentially just adjusting the height of a view within the footer.