2016-09-21 42 views
1

這是我的固定頁腳佈局。包含RecyclerViewFragment附於FrameLayout。但是RecyclerView的內容正在被頁腳佈局重疊。在android佈局中固定頁腳

<RelativeLayout 
android:layout_height="match_parent" 
android:layout_width="match_parent" 
android:orientation="vertical"> 

<FrameLayout 
    android:id="@+id/home_parent_framelayout" 
    android:layout_height="wrap_content" 
    android:layout_width="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

<LinearLayout 
    android:id="@+id/footer_linearlayout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:background="#f1c21e" 
    android:layout_alignParentBottom="true"> 

    <footer layout> 

    </LinearLayout> 

</RelativeLayout> 

回答

1

在你FrameLayout給物業

android:layout_above="@+id/footer_linearlayout" 

它會同時顯示FrameLayoutFooter

添加這樣:​​

<FrameLayout 
    android:id="@+id/home_parent_framelayout" 
    android:layout_height="wrap_content" 
    android:layout_width="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    android:layout_above="@+id/footer_linearlayout" /> 

說明:

LinearLayout當你正在創建修復頁腳Layout你必須給layout_above財產,以高度的父子不顯示Bottom Fix Footer意味着你的情況LinearLayout。身高所以顯示在屏幕上,您有FrameLayout父兒童給予android:layout_above="@+id/linearLayoutLinearLayout ..

+0

的FrameLayout具有高度包裹內容,所以當我添加機器人:layout_above =「@ + ID/footer_linearlayout」中的FrameLayout佈局上面顯示頁腳但在它上面留下了很多空的空間(framelayout),因爲它有高度包裝內容。 –

+0

然後將「FrameLayout」高度設置爲「match_parent」,它會將全部高度設置爲「FrameLayout」。它會解決你的問題。 – Ironman

+0

@Androidjack你解決了嗎? – Ironman

1

試試這個:

<?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"> 

    <FrameLayout 
     android:id="@+id/home_parent_framelayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     android:layout_above="@+id/footer_linearlayout" /> 

    <LinearLayout 
     android:id="@+id/footer_linearlayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:background="#f1c21e" 
     android:orientation="horizontal"> 

//Your footer layout 
    </LinearLayout> 

</RelativeLayout>