2015-11-14 60 views
1

這是我活動的佈局:片段佈局接管工具欄和浮動按鈕

<?xml version="1.0" encoding="utf-8"?> 
    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    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:context="name.company.newapp.HomeScreen"> 

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

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

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

    <include layout="@layout/content_home_screen" 
     android:layout_below="@id/bar" 
     android:layout_height="match_parent" 
     android:layout_width="match_parent" /> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|end" 
     android:layout_margin="@dimen/fab_margin" 
     android:src="@android:drawable/ic_dialog_email" /> 

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

這是包括什麼(content_home_screen)

<?xml version="1.0" encoding="utf-8"?> 
    <android.support.v4.widget.DrawerLayout 

     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/DrawerLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:elevation="7dp"> 

     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      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" 
      app:layout_behavior="@string/appbar_scrolling_view_behavior" 
      tools:context="name.company.newapp.HomeScreen" 
      tools:showIn="@layout/activity_home_screen"> 

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

     </RelativeLayout> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/RecyclerView" 
      android:layout_width="320dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="left" 

      android:background="#ffffff" 
      android:scrollbars="vertical"> 

     </android.support.v7.widget.RecyclerView> 

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

我的問題是,place_holder佔據整個屏幕(所有的)。我看不到浮動按鈕或佈局欄。我不知道如何做這項工作,除了只做一個佈局,不包含任何內容。

回答

2

至於我讀你有這樣的事情:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
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:context="name.company.newapp.HomeScreen"> 
<include layout="@layout/content_home_screen" 
    android:layout_below="@id/bar" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" /> 

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

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

<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom|end" 
    android:layout_margin="@dimen/fab_margin" 
    android:src="@android:drawable/ic_dialog_email" /> 

你提的問題是非常類似於此:Fragment overlaps my AppCompat toolbar

相關問題