Android - Material 设计 - NavigationView - 如何放置垂直滚动条?

Android - Material Design - NavigationView - How to put vertical scroll?

我在 compile 'com.android.support:design:22.2.1' 中使用 NavigationView 好吧,一切都很好,除非它没有垂直滚动 如何通过 xml 设置?

xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <!-- The main content view -->
    <foo>
    </foo>

    <!-- The navigation drawer -->
    <android.support.design.widget.NavigationView
        android:id="@+id/navigation_view"
        style="@style/NavigationViewTheme"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/navigation_drawer_header"
        app:menu="@menu/navigation_drawer_menu" />
</android.support.v4.widget.DrawerLayout>

android.support.design.widget.NavigationView

中尝试android:nestedScrollingEnabled="true"

我找到了一个解决方案,它似乎是设计库中的一个错误。更新库解决了我的问题

compile 'com.android.support:design:23.0.1'

在您的 activity java 文件中使用此代码

navigationView.bringToFront();
navigationView.setVerticalScrollBarEnabled(true);