0

I am just wondering how to create replica of this layout given below enter image description here

I tried

public class Utility {
        public void setListViewHeightBasedOnChildren(ListView listView) {
            ListAdapter listAdapter = listView.getAdapter(); 
            if (listAdapter == null) {
                // pre-condition
                return;
            }

            int totalHeight = 0;
            for (int i = 0; i < listAdapter.getCount(); i++) {
                View listItem = listAdapter.getView(i, null, listView);
                listItem.measure(0, 0);
                totalHeight += listItem.getMeasuredHeight();
            }

            ViewGroup.LayoutParams params = listView.getLayoutParams();
            params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
            listView.setLayoutParams(params);
        }

but it fixes height of ListView.

If you say with HeaderView/FooterView will do the job, then also HOW?.

If you say take custom layout(Linear or Relative) then also i can't take ScrollView within ScrollView.

Any other workaround?

Note: The data in ListView will be dynamic(can be more based on query).

Mohammed Azharuddin Shaikh
  • 41,633
  • 14
  • 96
  • 115

0 Answers0