Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation Drawer Menu Scroll Effect

I'm using NavigationView in DrawerLayout for my app's navigation menu here's the 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>

The problem: I don't even have enough items to scroll but I'm seeing this effect while trying to scroll, I want to disable this effect, thank you.
Scrolling effect

Update

trying both:

android:overScrollMode "never" in NavigationView

and

navigationView.setVerticalFadingEdgeEnabled(false);

didn't work.

I'm calling following method in onCreate() :

public void setupDrawerLayout() {
    drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
    ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolBar, R.string.drawer_open, R.string.drawer_close);
    drawerLayout.setDrawerListener(drawerToggle);
    drawerToggle.syncState();

    navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
}
like image 870
Canberk Ozcelik Avatar asked Jan 15 '16 13:01

Canberk Ozcelik


1 Answers

You are trying to disable the scrolling shadow. Try adding this to your NavigationView:

android:overScrollMode="never"

If the above solution doesn't work, try adding this in the onCreate() method of your Activity or wherever you setup your UI:

mNavigationView.setVerticalFadingEdgeEnabled(false);

UPDATE

After some more testing I found that indeed, the solutions posted in the answers so far are not working. However, I found this to work:

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

Add it in your onCreate() method, after you initialise the navigation drawer.

like image 157
Bandreid Avatar answered Oct 15 '22 22:10

Bandreid