Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在ScrollView中无法使用 #31

Open
heitaoa opened this issue Mar 19, 2016 · 0 comments
Open

在ScrollView中无法使用 #31

heitaoa opened this issue Mar 19, 2016 · 0 comments

Comments

@heitaoa
Copy link

heitaoa commented Mar 19, 2016

ScrollView中包括ZrcListView,无法触发加载更多事件。
注:ScrollView中包含ListView height已重新计算,不知道是不是需要针对ZrcListView需要另外计算。
计算代码如下:
private void setListViewHeightBasedOnChildren(ZrcListView listView) {

    // 获取ListView对应的Adapter 
    ListAdapter listAdapter = listView.getAdapter(); 
    if (listAdapter == null) { 
        return; 
    } 

    int totalHeight = 0; 
    int tmp = 0;
    for (int i = 0, len = listAdapter.getCount(); i < len; i++) { 
        // listAdapter.getCount()返回数据项的数目 
        View listItem = listAdapter.getView(i, null, listView); 
        // 计算子项View 的宽高 
        listItem.measure(0, 0);  
        // 统计所有子项的总高度 
        tmp = listItem.getMeasuredHeight();  
        totalHeight += tmp;  
    } 

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

// totalHeight += tmp/2;
params.height = totalHeight+ (listView.getDividerHeight() * (listAdapter.getCount() - 1));
// listView.getDividerHeight()获取子项间分隔符占用的高度
// params.height最后得到整个ListView完整显示需要的高度
listView.setLayoutParams(params);

    sv = (ScrollView)root.findViewById(R.id.video_cover_scroll);
    sv.smoothScrollTo(0, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant