卸下支持Android设计的导航抽屉式滚动条?

问题描述:

我刚刚更新从22.2.1支持设计库23.0.1并立即注意到了抽屉式导航滚动条的presence。我试图用

I just updated the support design library from 22.2.1 to 23.0.1 and immediately noticed the presence of a scrollbar in the navigation drawer. I tried to use

android:scrollbars="none"

但是,这并没有解决它。是否有任何其他的方式来删除滚动条?

But that didn't fix it. Is there any other way to remove the scrollbar?

不幸的是滚动条设置在 NavigationMenuView 布局不是在 NavigationView ,因为这个原因,如果你使用的android:滚动条=无滚动条仍然是present

Unfortunately the scrollbar is set in the NavigationMenuView layout not in the NavigationView, for this reason if you use android:scrollbars="none" the scrollbar is still present.

您可以做到这一点编程方式调用此方法:

You can do it programmatically calling this method:

private void disableNavigationViewScrollbars(NavigationView navigationView) {
    if (navigationView != null) {
        NavigationMenuView navigationMenuView = (NavigationMenuView) navigationView.getChildAt(0);
        if (navigationMenuView != null) {
            navigationMenuView.setVerticalScrollBarEnabled(false);
        }
    }
}