当前位置:网站首页>Drawerlayout suppress sideslip display

Drawerlayout suppress sideslip display

2022-07-07 13:29:00 The ancient moon cannot be seen by modern people. This moon onc

explain :

    Android DrawerLayout Sometimes the sideslip display is not required , At this time, it is necessary to prohibit side sliding .

    Just one line of code .

Code :

// No gesture sliding

drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);

// Open gesture slide

mDrawer_layout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED)

After initialization, add the following :

  DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.setDrawerListener(toggle);
        drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
        toggle.syncState();


 
————————————————

Reproduced in :https://blog.csdn.net/u012246458/article/details/80162799

原网站

版权声明
本文为[The ancient moon cannot be seen by modern people. This moon onc]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071104414170.html