2015-10-19 63 views
0

我在Eclipse中制作应用材质设计的应用程序,并且我是材质设计的初学者。让我解释一下我的问题:使用材质设计制作自定义导航抽屉

我做了什么:Android Getting Started with Material Design

enter image description here

我想要什么:

enter image description here

请指引我,不知道它怎么会做完了。

+0

我不明白你的要求。请具体说明。 – WonderKid

+0

你想要右侧的导航抽屉吗? – WonderKid

+0

是右侧的导航抽屉,还有额外的按钮,您可以在第二张图片(有列表/地图等)中看到 – userAndroid

回答

0

要切换导航抽屉的权利,你只需要设置layout_gravity结束。

<android.support.design.widget.NavigationView 
    android:id="@+id/navigation_view" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    android:layout_gravity="end" 
    /> 

从工具栏中删除汉堡包图标。在工具栏menu.xml中最右侧添加一个自定义汉堡包图标。

<item 
    android:id="@+id/action_open_drawer" 
    android:icon="@drawable/ic_hamburger_white_24dp" 
    android:menuCategory="secondary" 
    android:orderInCategory="1" 
    android:title="drawer" 
    app:showAsAction="always" /> 

现在在action_open_drawer按钮,点击您OnOptionSelected方法打开的抽屉。

if (id == R.id.action_open_drawer) { 

     if (drawerLayout.isDrawerOpen(GravityCompat.END)) 
      drawerLayout.closeDrawer(GravityCompat.END); 
     else { 
      drawerLayout.openDrawer(GravityCompat.END); 
     } 
    }