2012-02-01 82 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