解决方案 »

  1.   

    onMeasure不要 写着个方法,你在自定义的listview的时候,重写的ontounch事件,,在按下的时候屏蔽父类拦截事件,否则不屏蔽,你要是需要给我邮箱,我给你demo
      

  2.   

    给你一个工具类吧,完美解决问题。
    package com.woyou.utils;import android.view.View;
    import android.view.ViewGroup;
    import android.widget.ListAdapter;
    import android.widget.ListView;/**
     * 如何在ScrollView中嵌套ListView
     * 
     * @author shenzhou 2015年1月17日
     */
    public class ScrollViewUtils { public static 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);
    }
    }不过listView的adapter适配器布局只能是LinearLayout的,记住了,否则会出问题的...暂时没找到解决方法
      

  3.   


    本人邮箱,[email protected]谢谢了!!
      

  4.   


    完美解决!之前没注意到item的根布局必须要LinearLayout,换成LinearLayout就解决问题了。谢谢了!!