2014-12-03 67 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