2016-11-11 127 views
1

我是Android應用程序的新手,剛開始學習。我正在寫使用抽屜式導航和片段導航抽屜中的片段佈局Android應用程序

這是工作的罰款與佈局,但與片段內容是隱藏的導航頂欄裏面

期待的顯示就像是一個應用程序是

expected

但是,這是佈局如何

enter image description here

NEXT DATE背後隱藏的動作條

代碼佈局

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawer_layout" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:openDrawer="start" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="com.thecoders.periodtracker.MainActivity"> 

    <android.support.design.widget.CoordinatorLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true"> 

     <android.support.design.widget.AppBarLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:theme="@style/AppTheme.AppBarOverlay"> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:background="?attr/colorPrimary" 
       app:popupTheme="@style/AppTheme.PopupOverlay" /> 

     </android.support.design.widget.AppBarLayout> 

     <FrameLayout 
      android:id="@+id/content_frame" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 

    </android.support.design.widget.CoordinatorLayout> 

    <android.support.design.widget.NavigationView 
     android:id="@+id/nav_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="true" 
     app:headerLayout="@layout/nav_header_main" 
     app:menu="@menu/activity_main_drawer" /> 

</android.support.v4.widget.DrawerLayout> 
+0

我建議嘗試刪除'機器人:fitsSystemWindows = 「真」' –

+0

有兩個次數'fitsSystemWindows的= 「真正的」'。試圖刪除兩個,但相同的輸出屏幕 –

回答

2

中添加這您FrameLayout裏。

app:layout_behavior="@string/appbar_scrolling_view_behavior" 

這也是。

xmlns:app="http://schemas.android.com/apk/res-auto" 
+0

Thankx @Android插孔,它的工作... –

0

添加TOPMARGIN在Framelayout

android:layout_marginTop="56dp" 
0

把一個相對佈局協調佈局內添加規則,以你的框架佈局,它應該是低於像下面appBarLayout東西:

<android.support.design.widget.CoordinatorLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 

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

     <android.support.design.widget.AppBarLayout 
      android:id="@+id/app_bar_layout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:theme="@style/AppTheme.AppBarOverlay"> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:background="?attr/colorPrimary" 
       app:popupTheme="@style/AppTheme.PopupOverlay"/> 

     </android.support.design.widget.AppBarLayout> 

     <FrameLayout 
      android:id="@+id/content_frame" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_below="@+id/app_bar_layout"/> 
    </RelativeLayout> 

</android.support.design.widget.CoordinatorLayout> 
0

你或許應該換你framLayout一個NestedSCrollView內(不盡管必要)。

關鍵是這一行:

應用:layout_behavior = 「@字符串/ appbar_scrolling_view_behavior」

的CoordinatorLayout的孩子會表現不同,如果你給他們一個 Behavior

<android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_gravity="fill_vertical" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <!-- Rest of the code there --> 

     </FrameLayout> 
</android.support.v4.widget.NestedScrollView>