2014-12-03 42 views
0

這是我工作的xml代碼..現在我想在不改變列表視圖的高度的情況下在列表視圖下添加兩個文本視圖和一個按鈕。無法在列表視圖下方添加文字視圖和按鈕使用

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/linearlayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

     <ListView 
      android:id="@+id/orderlist" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:divider="#778899" 
      android:dividerHeight="1dp" > 
     </ListView> 

     <LinearLayout 
      android:id="@+id/layout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:orientation="vertical" > 

      <include layout="@layout/footer" /> 
     </LinearLayout> 

    </RelativeLayout> 

回答

0

添加android:layout_above="@+id/layout"列表視圖。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/linearlayout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" > 

<ListView 
    android:id="@+id/orderlist" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/layout" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" 
    android:divider="#778899" 
    android:dividerHeight="1dp" > 
</ListView> 

<LinearLayout 
    android:id="@+id/layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:orientation="vertical" > 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:text="Total Price : 20.00" 
     android:textColor="@android:color/black" 
     android:textSize="16sp" > 
    </TextView> 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="Buy" /> 

    <include 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     layout="@layout/footer" /> 
</LinearLayout> 

</RelativeLayout> 
0

更改listviewlistview控制研究

<ListView 
      android:id="@+id/orderlist" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_above="@+id/layout" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:divider="#778899" 
      android:dividerHeight="1dp" > 

     </ListView> 
0

更改列表視圖中添加android:layout_above="@+id/layout"如下

<ListView 
     android:id="@+id/orderlist" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:divider="#778899" 
     android:layout_above="@id/layout" 
     android:dividerHeight="1dp" > 
    </ListView> 
1

這在我結束工作。嘗試這樣的:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/linearlayout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <RelativeLayout 
     android:id="@+id/layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     > 

     <TextView 
      android:id="@+id/first" 
      android:layout_width="match_parent" 
      android:layout_height="40dp" 
      android:textColor="@android:color/white" 
      android:background="@android:color/background_dark" 
      android:text="First Text" /> 

     <TextView 
      android:id="@+id/sec" 
      android:layout_width="match_parent" 
      android:layout_height="40dp" 
      android:layout_below="@id/first" 
      android:textColor="@android:color/white" 
      android:background="@android:color/background_dark" 
      android:text="First Text" /> 

     <Button 
      android:id="@+id/button" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/sec" 
      android:text="First Text" /> 
    </RelativeLayout> 

    <ListView 
     android:id="@+id/orderlist" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/layout" 
     android:layout_alignParentLeft="true" 
     android:divider="#778899" 
     android:dividerHeight="1dp" > 
    </ListView> 

</RelativeLayout> 
+0

的RelativeLayout不需要取向。 – Piyush 2014-12-03 10:45:16

+0

但沒有頁腳....? – yamuna 2014-12-03 10:47:08