1

我一直在对我的应用程序进行材料设计检修。我很好奇你将如何改变activity_main xml代码来让导航抽屉滑动打开而不覆盖包含那个华丽的新切换按钮的工具栏。任何想法我怎么能做到这一点?获取导航抽屉滑动工具栏/操作栏下方

activity_main:

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

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:minHeight="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" /> 

    <FrameLayout 
     android:id="@+id/fragment_container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 
</LinearLayout> 

<RelativeLayout 
    android:id="@+id/drawerView" 
    android:layout_width="250dp" 
    android:layout_height="wrap_content" 
    android:layout_gravity="start" > 

    <ListView 
     android:id="@+id/drawerList" 
     android:layout_width="250dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="left" 
     android:background="@drawable/nav_border" 
     android:divider="@null" /> 
</RelativeLayout> 
<!-- 
    <fragment 
    android:id="@+id/fragment1" 
    android:name="com.shamu11.madlibsportable.MadlibsSelect" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" /> 
--> 

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

回答

1

材料设计指南说导航抽屉应该覆盖的一切之上。谷歌一直与他们的应用程序不一致;不过,我相信他们会将所有应用修复为导航抽屉重叠。

导航抽屉横跨屏幕的整个高度,抽屉位于状态栏后面。 http://www.google.com/design/spec/patterns/navigation-drawer.html

+0

我真的很喜欢他们与谷歌做了,尽管不一致玩。我认为这对我的抽屉会很好。任何这样做? – sanic 2014-11-08 20:14:30

+0

我会建议不要使用它。但是,如果您想要,请查看此答案。希望能帮助到你!^_^http://goo.gl/28XzLa 我也看到这个github项目,做同样的事情。 https://github.com/ikimuhendis/LDrawer – Atish 2014-11-08 21:03:39

+0

谢谢!欣赏它! – sanic 2014-11-08 21:42:19

3

我曾尝试使用以下布局实现它: Drawer.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    tools:context="com.example.toolbar.Drawer" > 

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



    <android.support.v4.widget.DrawerLayout 
     android:id="@+id/drawerLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@id/tool1" > 

     <FrameLayout 
      android:id="@+id/mainContent" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" > 
     </FrameLayout> 

     <!-- Nav drawer --> 

     <ListView 
      android:id="@+id/drawerList" 
      android:layout_width="240dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="left" 
      android:background="@android:color/white" 
      android:divider="@android:color/white" 
      android:dividerHeight="8dp" 
      android:drawSelectorOnTop="true" 
      android:headerDividersEnabled="true" /> 
    </android.support.v4.widget.DrawerLayout> 

</RelativeLayout> 

toolbar.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app1="http://schemas.android.com/apk/res/com.example.toolbar" 
    android:id="@+id/my_awesome_toolbar" 
    android:layout_width="fill_parent" 
    android:layout_height="75dp" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" 
    android:background="?attr/colorPrimary" 
    android:minHeight="?attr/actionBarSize" 
    app1:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
    app1:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" > 

</android.support.v7.widget.Toolbar> 
+0

作品,谢谢! – 2014-11-16 19:14:44

+0

嗨!!!。如果它的作品好心地接受它作为答案。预先感谢:) – 2014-11-17 11:07:57

+0

投了,但不能接受它作为答案不是我的问题..我想shamu11可以 – 2014-11-21 20:05:03