Android 导航抽屉菜单滚动效果

Android 导航抽屉菜单滚动效果,android,navigation-drawer,material-design,android-navigationview,Android,Navigation Drawer,Material Design,Android Navigationview,我正在为我的应用程序的导航菜单使用抽屉布局中的NavigationView以下是xml: <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/drawerLayout" android:

我正在为我的应用程序的导航菜单使用抽屉布局中的NavigationView以下是xml:

<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/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        android:foreground="?android:attr/selectableItemBackground"
        android:theme="@style/NavigationDrawerStyle"
        app:headerLayout="@layout/nav_header_main"
        app:itemIconTint="@color/textColor"
        app:itemTextColor="@color/textColor"
        app:menu="@menu/activity_main_drawer" />
    </android.support.v4.widget.DrawerLayout>

没用

我在
onCreate()
中调用以下方法:


您正在尝试禁用滚动阴影。 尝试将其添加到您的
导航视图中

android:overScrollMode="never"
如果上述解决方案不起作用,请尝试将其添加到活动的
onCreate()
方法中,或者在设置UI的任何位置:

mNavigationView.setVerticalFadingEdgeEnabled(false);
更新

经过更多的测试后,我发现,事实上,到目前为止,答案中公布的解决方案并不奏效。然而,我发现这是可行的:

for (int i = 0; i < navigationView.getChildCount(); i++) {
    navigationView.getChildAt(i).setOverScrollMode(View.OVER_SCROLL_NEVER);
}
for(int i=0;i

在初始化导航抽屉后,将其添加到您的
onCreate()
方法中。

它不起作用,我已经为不同版本的
NavigationView
DrawerLayout
添加了它,仍然看到滚动阴影@BandreidI会更喜欢使用
ifContentScrolls
,而不是
never
,以防OP在将来添加新项目。根据我的经验,如果内容在可滚动容器中,即使没有填充垂直空间,使用
ifContentScrolls
仍会显示滚动阴影。
android:overScrollMode="never"
mNavigationView.setVerticalFadingEdgeEnabled(false);
for (int i = 0; i < navigationView.getChildCount(); i++) {
    navigationView.getChildAt(i).setOverScrollMode(View.OVER_SCROLL_NEVER);
}