2016-01-08 80 views
0

我试图让导航抽屉内的片段填满屏幕(match_parent),即用户选择抽屉内的设置,设置frag打开填充屏幕。然而,对于我目前的布局,带有测试按钮的父(主)活动仍保留在屏幕上,即该片段不仅仅填充屏幕的一部分。我非常喜欢使用frag和nag抽屉,我确信它的简单,任何帮助表示赞赏。导航抽屉片段项目填写家长

我的活动布局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"> 

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

    <LinearLayout 
     android:id="@+id/container_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <include 
      android:id="@+id/toolbar" 
      layout="@layout/toolbar" /> 

    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/container_body" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="1" > 

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

      <Button 
       android:id="@+id/btn_category" 
       android:layout_width="100dp" 
       android:layout_height="100dp" 
       android:layout_centerInParent="true" 
       android:text="Movies" 
       /> 
     </RelativeLayout> 

    </LinearLayout> 

</LinearLayout> 

<fragment 
    android:id="@+id/fragment_navigation_drawer" 
    android:name="com.app.fragments.MainDrawerFragment" 
    android:layout_width="@dimen/nav_drawer_width" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    app:layout="@layout/fragment_main_navigation_drawer" 
    tools:layout="@layout/fragment_main_navigation_drawer" /> 

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

回答

0

我认为我设法解决这个问题一个更好地了解资产净值抽屉。

我已经从上面的DrawerLayout中删除了按钮,而是在抽屉ArrayList中创建了一个“home”片段,它是元素0(在此处添加按钮),我设置了主要活动来调用displayView()与从上面的按钮),现在设置是例如在ArrayList中的元素1,并简单地选择覆盖元素0(家)。

不知道它的正确修复,但现在正常工作。