you need to scroll the NavigationMenuView menu.
,
NavigationView navigationView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
}
@Override
public boolean onNavigationItemSelected(MenuItem item) {
((NavigationMenuView)navigationView.getChildAt(0)).smoothScrollToPosition(0);
return true;
}
EDIT: , , :
if (navigationView.getChildCount() > 0) {
View childView = navigationView.getChildAt(0);
try {
Method scroll = childView.getClass().getMethod("smoothScrollToPosition", int.class);
scroll.invoke(childView, 0);
} catch (NoSuchMethodException |
SecurityException |
IllegalAccessException |
InvocationTargetException e) {
Log.d(TAG, "smoothScrollToPosition", e);
}
}