布局文件采用“-dp”实现“少则紧随listView底部,多则固定底部”

主要实现的功能:

数据少的时候则布局显示的效果为:下面的button紧随listView下面;

数据多的时候:button则固定在整个界面的底部。

布局文件如下:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">
    <ListView android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:id="@+id/listView"
              android:layout_marginBottom="50dp"></ListView>
    <Button android:layout_width="match_parent"
            android:layout_height="48dp"
            android:layout_marginTop="-48dp"/>

</LinearLayout>
posted @ 2014-09-26 09:21  聪聪的豆芽  阅读(156)  评论(0编辑  收藏  举报