push activity on the right when open drawer

后端 未结 8 2033
隐瞒了意图╮
隐瞒了意图╮ 2020-12-07 11:29

I have implemented drawerlayout which slides from the right but it does not shift the activity the right like facebook does (See below image). How do I push the current acti

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-07 11:45

    This is really helpful. Put this snippet in your MainActivity.java

    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) {
     @Override
     public void onDrawerSlide(View drawerView, float slideOffset) {
        super.onDrawerSlide(drawerView, slideOffset);
        containerFrame.setTranslationX(slideOffset * drawerView.getWidth());
        drawerLayout.bringChildToFront(drawerView);
        drawerLayout.requestLayout();
        //below line used to remove shadow of drawer
        drawerLayout.setScrimColor(Color.TRANSPARENT);
    }//this method helps you to aside menu drawer
    };
    

提交回复
热议问题