2016-01-08 78 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(家)。

不知道它的正確修復,但現在正常工作。