<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ScrollView android:id="@+id/scrollView1" android:layout_width="match_parent" android:layout_height="fill_parent" android:layout_above="@+id/llybuttom" > <LinearLayout android:id="@+id/layout_business_detail" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <com.test.view.MyListView android:id="@+id/listView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:divider="@drawable/list_line" android:dividerHeight="1dip" /> </LinearLayout> </ScrollView> <LinearLayout android:id="@+id/llybuttom" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:background="@drawable/listviewbottom" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:text="@string/hello" /> </LinearLayout> </RelativeLayout>
必须重写ListView
package com.test.view; import android.content.Context; import android.util.AttributeSet; import android.widget.ListView; public class MyListView extends ListView { public MyListView(Context paramContext) { super(paramContext); } public MyListView(Context paramContext, AttributeSet paramAttributeSet) { super(paramContext, paramAttributeSet); } public MyListView(Context paramContext, AttributeSet paramAttributeSet, int paramInt) { super(paramContext, paramAttributeSet, paramInt); } //设置高度可以无限拉升 @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { heightMeasureSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, heightMeasureSpec); } }