您的位置:首页 > 其它

scrollView中嵌套ListView,ListView不能滚动的问题

2015-11-30 21:00 387 查看
解决方案:

通过代码计算ListView实际使用的高度

 

/**

 * @return返回ListView的LayoutParams

 */

public staticViewGroup.LayoutParams getHeight(Adapter sa,ListView lv){

View itemView = sa.getView(0, null, lv);

itemView.measure(0,0);

inth= itemView.getMeasuredHeight();

inttotalHeight = sa.getCount() * h ;

ViewGroup.LayoutParamsparams = lv.getLayoutParams();

//总高度=总的item的高度+item之间的分割线高度
params.height = totalHeight+ (lv.getDividerHeight() * (sa.getCount()- 1));
returnparams;

 

}

 

listView.setAdapter(sa);

//在设置Adapter之后再设置ListView的显示

ViewGroup.LayoutParamsmaxheight = new calcListViewHeightHelper().getHeight(sa, listView);

listView.setLayoutParams(maxheight);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  listview 焦点 滑动