2016-05-12 76 views
1

當我的應用在平板電腦上運行時,我試圖最小化或摺疊NavigationView/NavigationDrawer如何最小化NavigationView/NavigationDrawer?

我想要的結果是GMail應用程序使用的結果,請參見下面的屏幕截圖(您可以在左側看到所需的佈局摺疊)。

enter image description here

不存在任何方法或遵循實現這一模式?

回答

0

仔細閱讀this official NavigationDrawer guidelines後,我發現用錯了關鍵字我的問題:它被稱爲迷你導航抽屜(這就是爲什麼我第一次編輯我的問題)。

所以我能找到答案:

  1. 使用third party library,這是在this answer(!是的,我的問題是重複的)提議;
  2. 通過遵循this sample開發您自己的解決方案;請注意,您必須添加一些花哨的動畫和其他裝飾才能遵守材料設計指南。

任何方式,關鍵是要簡單地添加(在這種情況下FrameLayout)左到詳細視圖的餘量,例如:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.SlidingPaneLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <!--Master fragment--> 
    <fragment 
     android:name=".MainFragment" 
     android:layout_width="220dp" 
     android:layout_height="match_parent" 
     android:id="@+id/fragment_master"> 
    </fragment> 

    <!--Detail layout --> 
    <FrameLayout 
     android:layout_width="1000dp" 
     android:layout_height="match_parent" 
     android:layout_marginLeft="56dp"> 
    </FrameLayout> 
</android.support.v4.widget.SlidingPaneLayout>