使用导航抽屉移动屏幕

时间:2017-09-19 06:35:40

标签: java android android-layout navigation-drawer

我在android中实现了抽屉导航,在视觉上看起来像这样

enter image description here

但我想要一个像这样的导航抽屉

enter image description here

我尝试了很多但却无法这样做。我尝试了以下代码:

 drawer.addDrawerListener(new DrawerLayout.DrawerListener() {

            @Override
            public void onDrawerSlide(View drawerView, float slideOffset) {
                //Called when a drawer's position changes.
                drawer.findViewById(R.id.drawer_layout).setTranslationX(drawerView.getWidth() * slideOffset);
            }

            @Override
            public void onDrawerOpened(View drawerView) {
                //Called when a drawer has settled in a completely open state.
                //The drawer is interactive at this point.
                // If you have 2 drawers (left and right) you can distinguish
                // them by using id of the drawerView. int id = drawerView.getId();
                // id will be your layout's id: for example R.id.left_drawer
            }

            @Override
            public void onDrawerClosed(View drawerView) {
                // Called when a drawer has settled in a completely closed state.
            }

            @Override
            public void onDrawerStateChanged(int newState) {
                // Called when the drawer motion state changes. The new state will be one of STATE_IDLE, STATE_DRAGGING or STATE_SETTLING.
            }
        });

我没有得到正确的结果。这是屏幕截图:

enter image description here

0 个答案:

没有答案