【问题标题】:how to make hamburger menu fully visible如何使汉堡菜单完全可见
【发布时间】:2017-07-11 17:25:03
【问题描述】:

默认情况下会显示一半的汉堡,如屏幕截图的左上角所示。我想展示完整的汉堡包。代码取自https://developer.android.com/training/implementing-navigation/nav-drawer.html。我该怎么做?

【问题讨论】:

标签: android navigation-drawer


【解决方案1】:

您似乎正在使用非常古老的技术来创建Navigation Drawer。它的代码大约有 4 年的历史,似乎 perfect 关于 old version

仅供参考,以前这种 UI 是使用 DrawerLayoutListView 完成的。但是现在android本身正式引入了滑动面板菜单,引入了一个新的概念,叫做Navigation Drawer,我们结合DrawerLayoutNavigationView来实现想要的输出。

如何让汉堡菜单完全可见?

解决方案:

  1. 使用AppCompatActivity 代替Activity 并使用AppCompat 主题来实现您想要的输出。
  2. 使用NavigationView 而不是ListView

这是NavigationView的示例:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:id="@+id/drawer_layout"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:fitsSystemWindows="true">

     <!-- Your contents -->

     <android.support.design.widget.NavigationView
         android:id="@+id/navigation"
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
         android:layout_gravity="start"
         app:menu="@menu/my_navigation_items" />
 </android.support.v4.widget.DrawerLayout>

这里有一个很好的教程:Android Sliding Menu using Navigation Drawer

希望对你有帮助~

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-15
    • 2018-01-26
    • 1970-01-01
    相关资源
    最近更新 更多