2016-11-30 91 views
0

我正在開發一個Android應用程序,並使用屏幕頂部的工具欄和屏幕底部的導航欄。我正在使用單個活動來創建頂部和底部工具欄和片段,以更改工具欄之間的內容。但是,當片段中的內容超出屏幕大小時,底部欄會消失。當片段填滿屏幕時,Android底部工具欄消失

這裏是我的家活動的xml:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_home" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.rentables.testcenter.HomeActivity"> 


    <include 
     android:id="@+id/toolbar_main" 
     layout="@layout/toolbar_main" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 



    <fragment android:name="com.rentables.testcenter.HomeFragment" 
     android:id="@+id/fragment_place" 
     android:layout_weight="0" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     tools:layout="@layout/fragment_home" /> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:gravity="bottom"> 
     <include 
      android:id="@+id/toolbar_navigate" 
      layout="@layout/toolbar_navigate" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center|bottom"/> 
    </LinearLayout> 
</LinearLayout> 

即時猜測這是因爲內的線性佈局我的,但我不知道怎麼回事,得到的導航欄,以在底部留靜態的。任何幫助都是極好的。謝謝

回答

0

想通了。我只是將整個事物改爲相對佈局,擺脫了內部線性佈局,而不是重力,我使用alignParentBottom =「true」。