android 控件放在 listview 的下方 并且在 屏幕底部

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" 
    android:background="@drawable/bg2">
<!--
   layout_weight在此处的含义是所占剩余空间的比例,没指定layout_weight默认为0.
   在height上,首先给ListView分配0dip大小,给RelativeLayout分配wrap_content大小。
   然后把height剩余空间按照比例1:0分配各ListView和RelativeLayout.
-->
    <ListView 
         android:id="@+id/displayLV" 
         android:layout_width="fill_parent"
         android:layout_height="0dip" 
         android:drawSelectorOnTop="false"
         android:scrollbars="vertical" 
         android:layout_weight="1"/>
    <RelativeLayout 
         android:id="@+id/bottom"
         android:layout_width="fill_parent"
         android:background="@drawable/view_yuan_morelist"
         android:layout_height="wrap_content"> 
        <ImageButton
             android:id="@+id/searchBtn"
             android:src="@drawable/scan"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:padding="0dp"
             android:layout_centerHorizontal="true"
             />
        <TextView 
             android:layout_height="wrap_content"
             android:layout_width="wrap_content"
             android:layout_below="@+id/searchBtn"
             android:layout_centerHorizontal="true"
             android:text="扫描图书条码"/>           
    </RelativeLayout>
   
</LinearLayout>
     
原文地址:https://www.cnblogs.com/helloweworld/p/2677509.html