• android ScrollView中嵌套listview解决途径


    第一种方式:

    public void setListViewHeightBasedOnChildren(ListView listView) {  
    	    android.widget.ListAdapter listAdapter = listView.getAdapter();   
    	    if (listAdapter == null) {  
    	        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()));  
    	    listView.setLayoutParams(params);  
    	}
    

      第二种,自定义scrollview

    package com.bbt.util;
    
    import android.content.Context;
    import android.util.AttributeSet;
    import android.view.MotionEvent;
    import android.widget.ScrollView;
    
    public class MyScrollView extends ScrollView{
    
    	public MyScrollView(Context context) {
    		super(context);
    		// TODO Auto-generated constructor stub
    	}
    	 public MyScrollView(Context context, AttributeSet attrs) {
             super(context, attrs);
             // TODO Auto-generated constructor stub
     }
    	 public boolean onInterceptTouchEvent(MotionEvent ev) {
             // TODO Auto-generated method stub
             return false;
     }
    }
    

      

  • 相关阅读:
    敏感信息脱敏实现
    SpringBoot集成Swagger2
    CSS三大特性
    background
    background-attachment
    background-position
    background-repeat
    background-image
    background-color
    CSS元素显示模式
  • 原文地址:https://www.cnblogs.com/nanhai/p/2726611.html
Copyright © 2020-2023  润新知