6

Tôi đang sử dụng NavigationView trong DrawerLayout cho menu điều hướng ứng dụng của tôi ở đây là xml:Navigation Drawer menu Scroll Hiệu lực thi hành

<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> 

Vấn đề: Tôi thậm chí không có đủ các mục để di chuyển nhưng tôi thấy điều này có hiệu lực trong khi cố gắng cuộn, tôi muốn vô hiệu hóa hiệu ứng này, cảm ơn bạn.
Scrolling effect

Cập nhật

thử cả hai:

android:overScrollMode "never" in NavigationView 

navigationView.setVerticalFadingEdgeEnabled(false); 

đã không làm việc.

Tôi gọi phương pháp sau đây trong 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); 
} 

Trả lời

7

Bạn đang cố gắng vô hiệu hóa cái bóng di chuyển. Hãy thử thêm này để NavigationView của bạn:

android:overScrollMode="never" 

Nếu giải pháp trên không làm việc, hãy thử thêm này trong phương pháp onCreate() của hoạt động của bạn hoặc bất cứ nơi nào bạn thiết lập giao diện người dùng của bạn:

mNavigationView.setVerticalFadingEdgeEnabled(false); 

CẬP NHẬT

Sau một số thử nghiệm khác, tôi thấy rằng thực sự, các giải pháp được đăng trong các câu trả lời cho đến nay không hoạt động. Tuy nhiên, tôi thấy việc này hoạt động:

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

Thêm phương thức này vào phương thức onCreate() sau khi bạn khởi chạy ngăn điều hướng.

+0

Nó không hoạt động, tôi đã thêm điều này cho cả 'NavigationView' và' DrawerLayout' trên các bản dựng khác nhau, vẫn thấy bóng cuộn @Bandreid –

+0

Tôi thích sử dụng 'ifContentScrolls' thay vì' never' if in trường hợp OP thêm các mục mới trong tương lai. –

+2

Theo kinh nghiệm của tôi, việc sử dụng 'ifContentScrolls' sẽ vẫn hiển thị bóng cuộn nếu nội dung nằm trong vùng chứa có thể cuộn, ngay cả khi nó không lấp đầy khoảng trống dọc. – Bandreid

Các vấn đề liên quan