/** * 動態設置listView的高度 count 總條目 */ private static void setListViewHeight(ListView listView, BaseAdapter adapter, int count) { if (count>4){ int totalHeight = 0; for (int i = 0; i < 4; i++) { View listItem = adapter.getView(i, null, listView); listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutParams params = listView.getLayoutParams(); params.height = totalHeight + (listView.getDividerHeight() * count); listView.setLayoutParams(params); } }
動態設置listView的高度 count 總條目
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.