2016-05-12 77 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>