Full width Navigation Drawer

后端 未结 14 784
名媛妹妹
名媛妹妹 2020-12-08 03:57

I\'d like to create a full width navigation drawer. Setting layout_width to match_parent on @+id/left_drawer yields in width of about

14条回答
  •  青春惊慌失措
    2020-12-08 04:40

    Because all these answers did not work on OS 6.0.1, I'll post here the solution that worked for me in combination with DrawerLayout + NavigationView.

    So all what I do is change the width of the NavigationView programatically:

    mNavigationView = (NavigationView) findViewById(R.id.nv_navigation);
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    DrawerLayout.LayoutParams params = (DrawerLayout.LayoutParams) mNavigationView.getLayoutParams();
    params.width = metrics.widthPixels;
    mNavigationView.setLayoutParams(params);
    

    This works for all screen sizes.

提交回复
热议问题