标签:android style blog io color os ar java sp
package com.bluedragonfly.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View.MeasureSpec;
import android.widget.GridView;
import android.widget.ListView;
public class InnerScrollListView extends ListView{
	 public InnerScrollListView(Context context, AttributeSet attrs) {
	        super(context, attrs);
	    }
	 
	    public InnerScrollListView(Context context) {
	        super(context);
	    }
	 
	    public InnerScrollListView(Context context, AttributeSet attrs, int defStyle) {
	        super(context, attrs, defStyle);
	    }
	
	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
                MeasureSpec.AT_MOST);
        super.onMeasure(widthMeasureSpec, expandSpec);
	}
}
重写ListView
然后在布局文件中
<ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:fillViewport="true"
        >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:focusable="true"
           android:focusableInTouchMode="true" >
    
            <InnerScrollListView/>
    
        </LinearLayout>    
android:fillViewport="true"
android:focusable="true"
android:focusableInTouchMode="true"这三个属性是必需的,否者会出现ScollerView会自动往下滑动一段距离标签:android style blog io color os ar java sp
原文地址:http://www.cnblogs.com/gfqFighting/p/4057184.html