android ScrollView和ListView固定底部
16lz
2021-01-26
<?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);}//设置高度可以无限拉升@Overrideprotected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {heightMeasureSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,MeasureSpec.AT_MOST);super.onMeasure(widthMeasureSpec, heightMeasureSpec);}}
更多相关文章
- android_camera_003
- 【Android】时间与日期Widget(DatePicker 与 TimePicker)
- android TextView 丰富多彩的字体样式代码
- Android带删除按钮的ListView
- numberPicker实现时间选择设置功能
- Android设置输入框和软键盘动态悬浮
- Android与HTML5交互模版
- 安卓加载网页
- popuwindow