2017-02-10 66 views
-1

几天我试图实现协调器布局,但仍然卡住。 我有一个活动,其中包括工具栏和Navigationview,这是常见的通过我的应用程序,它的单个窗口应用程序的片段签入和结帐。 基本上我的问题是如何实现只适用于一个片段和没有coordinatorlayout的片段的其余部分的协调器布局。我附加了我的活动布局和片段。 任何建议将不胜感激!协调器布局实现不起作用

acivity.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:openDrawer="right"> 

    <include 
     layout="@layout/co_ordinator_base" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <android.support.design.widget.NavigationView 
     android:id="@+id/nav_sliding_menu" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="true" 
     app:menu="@menu/nav_menu"> 

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

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

Fragment1.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <android.support.design.widget.TabLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/tabLayout" 
      app:tabTextColor="@android:color/white" 
      android:background="@color/colorPrimary"> 
     </android.support.design.widget.TabLayout> 
     <android.support.v4.view.ViewPager 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:id="@+id/viewPager"> 
     </android.support.v4.view.ViewPager> 

    </LinearLayout> 

回答