android的listview设置高度

1.ScrollView+listView配合着用

2.动态根据listView中item的高度计算listView的高度:

	public void setHeight(){
		int listViewHeight = 0;
		int adaptCount = comAdapter.getCount();
		for(int i=0;i<adaptCount;i++){
			View temp = comAdapter.getView(i,null,lsComment);
			temp.measure(0,0);
			listViewHeight += temp.getMeasuredHeight();
		}
		LayoutParams layoutParams = this.lsComment.getLayoutParams();
		layoutParams.width = LayoutParams.FILL_PARENT;
		layoutParams.height = listViewHeight;
		lsComment.setLayoutParams(layoutParams);
	}


import android.view.ViewGroup.LayoutParams;

你可能感兴趣的:(android的listview设置高度)