2012-02-01 78 views
0

在我的应用程序中,我有一个页眉(顶部)和一个页脚(底部)以及一个CustomListView。我已将HEADER & FOOTER固定并且不会滚动。但是放置在它们之间的ListView有一些与FOOTER重叠的组件。我不知何故希望我的CustomListView中的这些组件不要重叠页脚。有什么办法可以做到吗?Android CustomListView与其他组件重叠

我布局的代码如下─

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

<!-- Title Bar --> 

<include 
    android:id="@+id/title_bar" 
    android:layout_alignParentTop="true" 
    layout="@layout/title_bar" /> 

<!-- Settings Components list --> 

<ListView 
    android:id="@+id/custom_items_list" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/title_bar" 
    android:layout_weight="1" > 
</ListView> 

<!-- Options Bar --> 

<include 
    android:id="@+id/options_bar" 
    style="@style/btn_options_bar" 
    android:layout_alignParentBottom="true" 
    layout="@layout/options_bar" /> 

</RelativeLayout> 

回答

0

我终于找到了问题。问题是,(我不知道为什么,但)我需要设置layout_heightlayout_weight后再次<include>

对于那些有兴趣谁,更新的XML是 -

<?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="wrap_content" 
    android:orientation="vertical" > 

    <!-- Title Bar -->  
    <include 
     android:id="@+id/title_bar" 
     android:layout_alignParentTop="true" 
     layout="@layout/title_bar" /> 

    <!-- Options Bar -->  
    <include 
     android:id="@+id/options_bar" 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     style="@style/btn_options_bar" 
     android:layout_alignParentBottom="true" 
     layout="@layout/options_bar" /> 

    <!-- Settings components' list -->  
    <ListView 
     android:id="@+id/custom_items_list" 
     android:layout_above="@id/options_bar" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/title_bar"> 
    </ListView> 
</RelativeLayout> 
0

给你试过添加机器人:layout_above = “@ ID/options_bar” 到ListView?为此,您还必须将页脚声明移到布局文件中的ListView上方,以便您不引用尚未声明的ID。但即使选项栏会在ListView之前的布局中列出,但由于options_bar layout_alignParentBottom =“true”,它仍然会显示在它下面。

+0

是的,我试了一下。但在这种情况下,它甚至不显示ListView。在Logcat中也没有错误。 我也尝试过'android:layout:below =“@ id/custom_item_list”'但没有运气。 – Rajkiran 2012-02-02 06:42:27